Интерактивное меню (автозаполнение) в bash с диалогом (1)

429
nkamm

Таким образом, мы можем использовать, dialog --menu ...чтобы сделать меню. И мы можем быстро выбрать опцию по первой букве тега. Я хочу dialogзарегистрировать нажатия клавиш и выполнить автозаполнение. Например, у нас есть 3 варианта:

  • Применить миграции
  • Создать новую ветку
  • истреблять

Если я заполняю текстовое поле (поле, которое должно быть заполнено для выполнения автозаполнения) примерно так ter, то параметры меню уменьшаются до одного параметра

  • истреблять

Так что тогда я могу просто нажать tabи выбрать эту опцию (или перемещаться, используя стрелки, если есть больше опций)

Как? :)

1

1 ответ на вопрос

1
Thomas Dickey

dialog accepts the first character of labels (when in lists such as checkboxes) as a shortcut, and will cycle through matches if the character corresponds to multiple rows.

The feature is mentioned in documentation for the program and its library as abbreviation, e.g., (library):

dlg_button_to_char

Find the first uppercase character in the label, which we may use for an abbreviation. If the label is empty, return -1. If no uppercase character is found, return 0. Otherwise return the uppercase character.

Normally dlg_draw_buttons and dlg_char_to_button use the first uppercase character. However, they keep track of all of the labels and if the first has already been used in another label, they will continue looking for another uppercase character. This function does not have enough information to make that check.

It does not do autocompletion (doing that would require an additional window).