]> git.ozlabs.org Git - petitboot/commitdiff
ui/ncurses: Unify key bindings & key help text
authorJeremy Kerr <jk@ozlabs.org>
Fri, 31 Jan 2014 02:53:57 +0000 (10:53 +0800)
committerJeremy Kerr <jk@ozlabs.org>
Fri, 31 Jan 2014 02:59:42 +0000 (10:59 +0800)
This change is a small cleanup of the key bindings; we ensure that the
general key bindings are available (and documented) on all screens.

In order to keep things consistent, this change adds an initial UI
guidelines text file, which documents the general key bindings.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
ui/ncurses/Makefile.am
ui/ncurses/nc-boot-editor.c
ui/ncurses/nc-config.c
ui/ncurses/nc-menu.c
ui/ncurses/nc-textscreen.c
ui/ncurses/ui-guidelines.text [new file with mode: 0644]

index 877dc11b3e279bab64201d73b97cb9002a50b140..ded3193f21e4ddb9614a503f2dd3abdefb8d5172 100644 (file)
@@ -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
index 432a92a7e2f2205d35aa39d2327c2802d30da4a6..329699ab8ebdb6842369d9ad680cacf8e145907a 100644 (file)
@@ -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) {
index 8d68e7446499e700a16122c6726da68d6171ac98..64d0619b66c66703dc64c9d08c9b50e07dfc3903 100644 (file)
@@ -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);
index 7533f30e4df8d96048ae6e33c559629af5a81aee..cd7c54e6b67c4dde5fe39d0f613ae701fc6e568e 100644 (file)
@@ -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),
index d5b894e8f8c87d5868e1cdd44db52c56a7b975c8..ad91f61e4c14b83cb499c8235cdd737d04232490 100644 (file)
@@ -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 (file)
index 0000000..c416fc7
--- /dev/null
@@ -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
+