diff options
-rw-r--r-- | ui/ncurses/Makefile.am | 1 | ||||
-rw-r--r-- | ui/ncurses/nc-boot-editor.c | 2 | ||||
-rw-r--r-- | ui/ncurses/nc-config.c | 17 | ||||
-rw-r--r-- | ui/ncurses/nc-menu.c | 7 | ||||
-rw-r--r-- | ui/ncurses/nc-textscreen.c | 3 | ||||
-rw-r--r-- | ui/ncurses/ui-guidelines.text | 44 |
6 files changed, 70 insertions, 4 deletions
diff --git a/ui/ncurses/Makefile.am b/ui/ncurses/Makefile.am index 877dc11..ded3193 100644 --- a/ui/ncurses/Makefile.am +++ b/ui/ncurses/Makefile.am @@ -65,5 +65,6 @@ petitboot_ps3_nc_SOURCES = ps3-main.c petitboot_ps3_nc_LDADD = $(common_libs) $(libdir)/libps3-utils.so #petitboot_ps3_nc_LDFLAGS = -L$(libdir) -lps3-utils +EXTRA_DIST = ui-guidelines.text MAINTAINERCLEANFILES = Makefile.in diff --git a/ui/ncurses/nc-boot-editor.c b/ui/ncurses/nc-boot-editor.c index 432a92a..329699a 100644 --- a/ui/ncurses/nc-boot-editor.c +++ b/ui/ncurses/nc-boot-editor.c @@ -538,7 +538,7 @@ struct boot_editor *boot_editor_init(struct cui *cui, "Petitboot Option Editor"); boot_editor->scr.frame.rtitle = NULL; boot_editor->scr.frame.help = talloc_strdup(boot_editor, - "Enter=accept"); + "tab=next, shift+tab=previous, x=exit, h=help"); nc_scr_frame_draw(&boot_editor->scr); if (item) { diff --git a/ui/ncurses/nc-config.c b/ui/ncurses/nc-config.c index 8d68e74..64d0619 100644 --- a/ui/ncurses/nc-config.c +++ b/ui/ncurses/nc-config.c @@ -118,10 +118,23 @@ static void config_screen_process_key(struct nc_scr *scr, int key) bool handled; handled = widgetset_process_key(screen->widgetset, key); + + if (!handled) { + switch (key) { + case 'x': + case 27: /* esc */ + screen->exit = true; + break; + case 'h': + screen->show_help = true; + break; + } + } + if (screen->exit) { screen->on_exit(screen->cui); - } else if (screen->show_help || (!handled && key == 'h')) { + } else if (screen->show_help) { screen->show_help = false; cui_show_help(screen->cui, "System Configuration", config_help_text); @@ -689,7 +702,7 @@ struct config_screen *config_screen_init(struct cui *cui, "Petitboot System Configuration"); screen->scr.frame.rtitle = NULL; screen->scr.frame.help = talloc_strdup(screen, - "tab=next, shift+tab=previous"); + "tab=next, shift+tab=previous, x=exit, h=help"); nc_scr_frame_draw(&screen->scr); scrollok(screen->scr.sub_ncw, true); diff --git a/ui/ncurses/nc-menu.c b/ui/ncurses/nc-menu.c index 7533f30..cd7c54e 100644 --- a/ui/ncurses/nc-menu.c +++ b/ui/ncurses/nc-menu.c @@ -227,9 +227,15 @@ static void pmenu_process_key(struct nc_scr *scr, int key) case KEY_UP: pmenu_move_cursor(menu, REQ_UP_ITEM); break; + case KEY_BTAB: + pmenu_move_cursor(menu, REQ_PREV_ITEM); + break; case KEY_DOWN: pmenu_move_cursor(menu, REQ_DOWN_ITEM); break; + case '\t': + pmenu_move_cursor(menu, REQ_NEXT_ITEM); + break; case 'e': if (item->on_edit) item->on_edit(item); @@ -250,6 +256,7 @@ static void pmenu_process_key(struct nc_scr *scr, int key) case 'c': cui_show_config(cui_from_arg(scr->ui_ctx)); break; + case KEY_F(1): case 'h': if (menu->help_text) cui_show_help(cui_from_arg(scr->ui_ctx), diff --git a/ui/ncurses/nc-textscreen.c b/ui/ncurses/nc-textscreen.c index d5b894e..ad91f61 100644 --- a/ui/ncurses/nc-textscreen.c +++ b/ui/ncurses/nc-textscreen.c @@ -144,6 +144,7 @@ void text_screen_process_key(struct nc_scr *scr, int key) switch (key) { case 'x': + case 27: /* esc */ screen->on_exit(screen->cui); break; case KEY_DOWN: @@ -176,7 +177,7 @@ void text_screen_set_help(struct text_screen *screen, const char *title, { screen->help_title = title; screen->help_text = text; - screen->scr.frame.help = "x=exit h=help"; + screen->scr.frame.help = "x=exit, h=help"; } static int text_screen_post(struct nc_scr *scr) diff --git a/ui/ncurses/ui-guidelines.text b/ui/ncurses/ui-guidelines.text new file mode 100644 index 0000000..c416fc7 --- /dev/null +++ b/ui/ncurses/ui-guidelines.text @@ -0,0 +1,44 @@ +Petitboot ncurses UI guidelines + +General key bindings: + + x: Exit the current screen + + When the focus is on a text-input field, this key will be treated + litereally (ie, it inputs an 'x' in to the text field). Because of this, + we should avoid putting a text field as the first field on a screen. + + We also support 'Esc' as a secondary exit key, but this can cause + problems with some terminals (because Esc is used to initiate an input + escape sequence, it causes ncurses to delay, waiting for more keys). + So, Esc should not be listed as a key in the UI help. + + h: Show help + + Same restrictions as the 'x' key with text input widgets. We support F1 + too, but this is often used by the actual terminal emulator to show help + locally instead. + +Form key bindings: + + tab: Next widget + shift+tab: Previous widget + + down: Next widget + up: Previous widget + +Text screen key bindings: + + up/down: scroll + +Menu key bindings: + + up: Next item + down: Previous item + + tab: Next item + shift+tab: Previous item + + Enter: select item + Space: select item + |