[hci] Allow tab key to be used to cycle through UI elements

Add support for wraparound scrolling and allow the tab key to be used
to move forward through a list of elements, wrapping back around to
the beginning of the list on overflow.

This is mildly useful for a menu, and likely to be a strong user
expectation for an interactive form.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2024-06-20 12:21:57 -07:00
parent 76e0933d78
commit 122777f789
4 changed files with 87 additions and 34 deletions

View File

@@ -175,9 +175,9 @@ static int menu_loop ( struct menu_ui *ui, struct menu_item **selected ) {
struct menu_item *item;
unsigned long timeout;
unsigned int previous;
unsigned int move;
int key;
int i;
int move;
int chosen = 0;
int rc = 0;
@@ -192,7 +192,7 @@ static int menu_loop ( struct menu_ui *ui, struct menu_item **selected ) {
ui->timeout -= timeout;
/* Get key */
move = 0;
move = SCROLL_NONE;
key = getkey ( timeout );
if ( key < 0 ) {
/* Choose default if we finally time out */
@@ -228,7 +228,7 @@ static int menu_loop ( struct menu_ui *ui, struct menu_item **selected ) {
if ( item->name ) {
chosen = 1;
} else {
move = +1;
move = SCROLL_DOWN;
}
}
break;

View File

@@ -381,8 +381,8 @@ static void select_settings ( struct settings_ui *ui,
static int main_loop ( struct settings *settings ) {
struct settings_ui ui;
unsigned int previous;
unsigned int move;
int redraw = 1;
int move;
int key;
int rc;