Interaktives Menü (Autovervollständigung) in Bash mit Dialog (1)

492
nkamm

So können wir dialog --menu ...ein Menü erstellen. Und wir können die Option schnell nach dem ersten Buchstaben des Tags auswählen. Ich möchte dialogTastatureingaben registrieren und die automatische Vervollständigung durchführen. ZB haben wir 3 Möglichkeiten:

  • Migrationen anwenden
  • Neuen Zweig erstellen
  • Vernichten

Wenn ich das Textfeld (ein Feld, das zur Ausführung der Autovervollständigung ausgefüllt werden soll) so füllen, werden die Menüoptionen terauf eine Option verkleinert

  • Vernichten

Dann kann ich einfach tabdiese Option auswählen und auswählen (oder mit Pfeilen navigieren, wenn weitere Optionen vorhanden sind).

Wie? :)

1

1 Antwort auf die Frage

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).