diff options
author | Michael Brown | 2013-03-06 16:05:30 +0100 |
---|---|---|
committer | Michael Brown | 2013-03-06 16:11:49 +0100 |
commit | c08025137be3109adb008a4dfd8f023ae3845519 (patch) | |
tree | 8b466c5d44890813da8225ba46cd86b92b22dacf /src/hci/tui | |
parent | [menu] Prevent character code zero from acting as a shortcut key (diff) | |
download | ipxe-c08025137be3109adb008a4dfd8f023ae3845519.tar.gz ipxe-c08025137be3109adb008a4dfd8f023ae3845519.tar.xz ipxe-c08025137be3109adb008a4dfd8f023ae3845519.zip |
[menu] Prevent separators with shortcut keys from being selected
Nothing currently prevents a menu separator from being assigned a
shortcut key, and then from being selected using that shortcut key.
This produces an inconsistency in the user interface, since separators
cannot be selected by other means of menu navigation (arrow keys, page
up/down, etc).
It would be trivial to prevent separators from being assigned shortcut
keys, but this would eliminate one potentially useful use case: having
a large menu and using shortcut keys to jump to a section within the
menu.
Fix by treating a shortcut key on a separator as equivalent to "select
the separator, then press the down arrow key". This has the effect of
moving to the first non-separator menu item following the specified
separator, which is probably the most intuitive behaviour. (The
existing logic for moving the selection already handles the various
nasty corner cases such as a menu ending with one or more separators.)
Reported-by: Ján ONDREJ (SAL) <ondrejj@salstar.sk>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/hci/tui')
-rw-r--r-- | src/hci/tui/menu_ui.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/hci/tui/menu_ui.c b/src/hci/tui/menu_ui.c index 49740795..d5636f8b 100644 --- a/src/hci/tui/menu_ui.c +++ b/src/hci/tui/menu_ui.c @@ -247,13 +247,17 @@ static int menu_loop ( struct menu_ui *ui, struct menu_item **selected ) { i = 0; list_for_each_entry ( item, &ui->menu->items, list ) { - if ( item->shortcut && - ( item->shortcut == key ) ) { - ui->selected = i; + if ( ! ( item->shortcut && + ( item->shortcut == key ) ) ) { + i++; + continue; + } + ui->selected = i; + if ( item->label ) { chosen = 1; - break; + } else { + move = +1; } - i++; } break; } @@ -284,12 +288,10 @@ static int menu_loop ( struct menu_ui *ui, struct menu_item **selected ) { draw_menu_item ( ui, ui->selected ); } - /* Refuse to choose unlabelled items (i.e. separators) */ - item = menu_item ( ui->menu, ui->selected ); - if ( ! item->label ) - chosen = 0; - /* Record selection */ + item = menu_item ( ui->menu, ui->selected ); + assert ( item != NULL ); + assert ( item->label != NULL ); *selected = item; } while ( ( rc == 0 ) && ! chosen ); |