]> git.ozlabs.org Git - petitboot/commitdiff
ui/ncurses: Add help text to nc-menu & generic-main
authorJeremy Kerr <jk@ozlabs.org>
Tue, 10 Dec 2013 07:08:47 +0000 (15:08 +0800)
committerJeremy Kerr <jk@ozlabs.org>
Fri, 31 Jan 2014 00:46:34 +0000 (08:46 +0800)
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
ui/ncurses/Makefile.am
ui/ncurses/generic-main-help.c [new file with mode: 0644]
ui/ncurses/generic-main.c
ui/ncurses/nc-menu.c
ui/ncurses/nc-menu.h

index 81602987b70139f471843e0e0d35a3e33b6c2c8c..5389ed9b9a9c28e119830a7ccce25dd7597b32ce 100644 (file)
@@ -55,7 +55,7 @@ sbin_PROGRAMS += petitboot-ps3-nc
 endif
 
 
-petitboot_nc_SOURCES = generic-main.c
+petitboot_nc_SOURCES = generic-main.c generic-main-help.c
 petitboot_nc_LDADD = $(common_libs)
 
 petitboot_ps3_nc_SOURCES = ps3-main.c
diff --git a/ui/ncurses/generic-main-help.c b/ui/ncurses/generic-main-help.c
new file mode 100644 (file)
index 0000000..d3c5662
--- /dev/null
@@ -0,0 +1,17 @@
+
+const char *main_menu_help_text =
+"From the main menu screen, select a boot option. The options displayed are \
+available on the system and the network.\n\
+\n\
+To select a boot option, press Enter.\n\
+\n\
+To make changes to an existing option, type E (edit).\n\
+\n\
+To add a new boot option, type N (new).\n\
+\n\
+To display information about the system, including the MAC addresses of each \
+network interface, type I (information).\n\
+\n\
+To make changes to the system configuration, type C (configure).\n\
+\n\
+To close the Petitboot interface, type X (exit).\n";
index aa5c2a59093bf669290e47b447bcd24135057883..7616788d6b7ea9dd583af198a982f24091794713 100644 (file)
@@ -36,6 +36,8 @@
 #include "ui/common/discover-client.h"
 #include "nc-cui.h"
 
+extern const char *main_menu_help_text;
+
 static void print_version(void)
 {
        printf("petitboot-nc (" PACKAGE_NAME ") " PACKAGE_VERSION "\n");
@@ -161,7 +163,7 @@ static struct pmenu *pb_mm_init(struct pb_cui *pb_cui)
                "Petitboot (" PACKAGE_VERSION ")");
        m->scr.frame.rtitle = NULL;
        m->scr.frame.help = talloc_strdup(m,
-               "Enter=accept, e=edit, n=new, x=exit");
+               "Enter=accept, e=edit, n=new, x=exit, h=help");
        m->scr.frame.status = talloc_strdup(m, "Welcome to Petitboot");
 
        i = pmenu_item_init(m, 0, " ");
@@ -181,6 +183,9 @@ static struct pmenu *pb_mm_init(struct pb_cui *pb_cui)
                goto fail_setup;
        }
 
+       m->help_title = "main menu";
+       m->help_text = main_menu_help_text;
+
        menu_opts_off(m->ncm, O_SHOWDESC);
        set_menu_mark(m->ncm, " *");
        set_current_item(m->ncm, i->nci);
index d2048e1c3561591bd615a82fcb57ef58b36e27b0..7533f30e4df8d96048ae6e33c559629af5a81aee 100644 (file)
@@ -250,6 +250,11 @@ static void pmenu_process_key(struct nc_scr *scr, int key)
        case 'c':
                cui_show_config(cui_from_arg(scr->ui_ctx));
                break;
+       case 'h':
+               if (menu->help_text)
+                       cui_show_help(cui_from_arg(scr->ui_ctx),
+                                       menu->help_title, menu->help_text);
+               break;
        default:
                menu_driver(menu->ncm, key);
                break;
index 4639c5537bd38d00d16115eb472aa4951acd17a9..f5e947d24ea9f59ebe6e5f81361f43786230d043 100644 (file)
@@ -90,6 +90,8 @@ struct pmenu {
        ITEM **items;
        unsigned int item_count;
        unsigned int insert_pt;
+       const char *help_title;
+       const char *help_text;
        int (*hot_key)(struct pmenu *menu, struct pmenu_item *item, int c);
        void (*on_exit)(struct pmenu *menu);
        void (*on_new)(struct pmenu *menu);