menu: add MENU HELP
authorH. Peter Anvin <hpa@zytor.com>
Sun, 27 Jun 2010 03:28:45 +0000 (20:28 -0700)
committerH. Peter Anvin <hpa@zytor.com>
Sun, 27 Jun 2010 03:28:45 +0000 (20:28 -0700)
Add a feature to display fullscreen help via menu selection entry
(inspired by the Debian install disc menus.)

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
com32/menu/menu.h
com32/menu/menumain.c
com32/menu/readconfig.c
doc/menu.txt

index 63e1859..36c5669 100644 (file)
@@ -49,6 +49,7 @@ enum menu_action {
     MA_QUIT,                   /* Quit to CLI */
     MA_EXIT,                   /* Exit to higher-level menu */
     MA_EXIT_UNRES,             /* Unresolved exit */
+    MA_HELP,                   /* Show help text */
 };
 
 struct menu_entry {
@@ -58,6 +59,7 @@ struct menu_entry {
     const char *passwd;
     char *helptext;
     const char *cmdline;
+    const char *background;
     struct menu *submenu;
     struct menu_entry *next;   /* Linked list of all labels across menus */
     int entry;                 /* Entry number inside menu */
index 5d85018..06725f3 100644 (file)
@@ -921,6 +921,13 @@ static const char *run_menu(void)
                    clear = 1;
                    draw_row(entry - top + 4 + VSHIFT, -1, top, 0, 0);
                    break;
+               case MA_HELP:
+                   key = show_message_file(me->cmdline, me->background);
+                   /* If the exit was an F-key, display that help screen */
+                   show_fkey(key);
+                   done = 0;
+                   clear = 1;
+                   break;
                default:
                    done = 0;
                    break;
index 5685e6f..ca9c35e 100644 (file)
@@ -372,6 +372,11 @@ static void record(struct menu *m, struct labeldata *ld, const char *append)
            me->submenu = ld->submenu;
            break;
 
+       case MA_HELP:
+           me->cmdline = refstr_get(ld->kernel);
+           me->background = refstr_get(ld->append);
+           break;
+
        default:
            break;
        }
@@ -834,6 +839,24 @@ static void parse_config_file(FILE * f)
                }
            } else if (looking_at(p, "start")) {
                start_menu = m;
+           } else if (looking_at(p, "help")) {
+               if (ld.label) {
+                   ld.action = MA_HELP;
+                   p = skipspace(p + 4);
+
+                   refstr_put(ld.kernel);
+                   ld.kernel = refdup_word(&p);
+
+                   if (ld.append) {
+                       refstr_put(ld.append);
+                       ld.append = NULL;
+                   }
+
+                   if (*p) {
+                       p = skipspace(p);
+                       ld.append = refdup_word(&p); /* Background */
+                   }
+               }
            } else if ((ep = looking_at(p, "resolution"))) {
                int x, y;
                x = strtoul(ep, &ep, 0);
index af93558..e2dd1e1 100644 (file)
@@ -497,16 +497,23 @@ MENU VSHIFT 0
        screen (25 for text mode, 28 for VESA graphics mode.)
 
 
-F1 textfile background
+F1 textfile [background]
 ...
-F12 textfile background
+F12 textfile [background]
 
        Displays full-screen help (also available at the command line.)
        The same control code sequences as in the command line
        interface are supported, although some are ignored.
 
-       Additionally, a second argument allows a different background
-       image (see MENU BACKGROUND for supported formats) to be displayed.
+       Additionally, a optional second argument allows a different
+       background image (see MENU BACKGROUND for supported formats)
+       to be displayed.
+
+
+MENU HELP textfile [background]
+
+       Creates a menu entry which, when selected, displays
+       full-screen help in the same way as the F-key help.
 
 
 The menu system honours the TIMEOUT command; if TIMEOUT is specified