bootloader: additional keyboard commands

In the boot menu, tab cycles between the menu items.

In the pager for logs, j and k allow to scroll the log (vim style keys).

These allow using the pager and menu on Sun machines, where Openboot
does not manage the keyboard arrow keys. It may be possible to get more
low-level input from the keyboard openboot device, but I think it is not
worth the effort for now, especially as we would need different handling
for the local keyboard and for serial ports.

Change-Id: I5fe74eb9f7a952ae49ae3c8a6bfae6ba4a16ae07
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2368
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
This commit is contained in:
PulkoMandy 2020-03-16 16:27:33 +01:00 committed by waddlesplash
parent 9ebce09880
commit 442a131da7
2 changed files with 35 additions and 0 deletions

View File

@ -168,11 +168,15 @@ pager(const PagerTextSource& textSource)
case TEXT_CONSOLE_KEY_DOWN:
case TEXT_CONSOLE_KEY_RETURN:
case 'j':
case 'J':
// next line
topLine++;
break;
case TEXT_CONSOLE_KEY_UP:
case 'k':
case 'K':
// previous line
topLine--;
break;

View File

@ -465,6 +465,37 @@ run_menu(Menu* menu)
|| key == TEXT_CONSOLE_KEY_SPACE) {
if (item != NULL && invoke_item(menu, item, selected, key))
break;
} else if (key == '\t') {
if (item == NULL)
continue;
int32 oldSelected = selected;
// Use tab to cycle between items (on some platforms, arrow keys
// are not available)
selected = select_next_valid_item(menu, selected + 1);
if (selected == oldSelected)
selected = first_selectable_item(menu);
// check if selected has changed
if (selected != oldSelected) {
MenuItem *item = menu->ItemAt(selected);
if (item != NULL)
item->Select(true);
make_item_visible(menu, selected);
// make sure that the new selected entry is visible
if (sMenuOffset > selected
|| sMenuOffset + menu_height() <= selected) {
if (sMenuOffset > selected)
sMenuOffset = selected;
else
sMenuOffset = selected + 1 - menu_height();
draw_menu(menu);
}
}
} else if (key == TEXT_CONSOLE_KEY_ESCAPE
&& menu->Type() != MAIN_MENU) {
// escape key was hit