diff options
author | H. Peter Anvin <hpa@zytor.com> | 2007-03-05 17:40:09 -0800 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2007-03-05 17:40:09 -0800 |
commit | 58e98acb054add0809619eaa62a614679f36d7af (patch) | |
tree | 0eeae3eeeb5d2f8600256d438e4bab5ee11a253a | |
parent | 3ace5f4ec3e17f05eea53cb493da72c9df54bf16 (diff) | |
download | syslinux.git-58e98acb054add0809619eaa62a614679f36d7af.tar.gz syslinux.git-58e98acb054add0809619eaa62a614679f36d7af.tar.xz syslinux.git-58e98acb054add0809619eaa62a614679f36d7af.zip |
TEXT HELP: Multiline per-entry help messages in the simple menu system.syslinux-3.40-pre10
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | README.menu | 16 | ||||
-rw-r--r-- | com32/modules/menu.h | 1 | ||||
-rw-r--r-- | com32/modules/menumain.c | 44 | ||||
-rw-r--r-- | com32/modules/readconfig.c | 25 |
5 files changed, 84 insertions, 4 deletions
@@ -10,6 +10,8 @@ Changes in 3.40: * Fix API call 0x0019 (Read Disk.) * MENU AUTOBOOT, MENU TABMSG, MENU PASSPROMPT allows internationalization of menu messages. + * A new feature, TEXT HELP, allows the administrator to set + a multi-line help message for individual selections. Changes in 3.36: * MEMDISK: Disable EDD by default on floppy disks. EDD can be diff --git a/README.menu b/README.menu index 4eccf068..98526299 100644 --- a/README.menu +++ b/README.menu @@ -33,7 +33,7 @@ PROMPT 0 There are a few menu additions to the command line, all starting with -the keyword MENU; like the rest of the SYSLINUX config file +the keywords MENU or TEXT; like the rest of the SYSLINUX config file language, it is case insensitive: MENU TITLE title @@ -70,6 +70,7 @@ MENU LABEL label Keep in mind that the LABELs, not MENU LABELs, must be unique, or odd things will happen to the command-line. + MENU HIDE (Only valid after a LABEL statement.) @@ -83,6 +84,16 @@ MENU DEFAULT default is specified, use the first one. +TEXT HELP +Help text ... +... which can span multiple lines +ENDTEXT + + (Only valid after a LABEL statement.) + Specifies a help text that should be displayed when a particular + selection is highlighted. + + MENU PASSWD passwd (Only valid after a LABEL statement.) @@ -164,6 +175,7 @@ MENU COLOR element ansi foreground background shadow pwdentry Password box contents timeout_msg Timeout message timeout Timeout counter + help Help text "ansi" is a sequence of semicolon-separated ECMA-48 Set @@ -238,6 +250,7 @@ MENU COLOR element ansi foreground background shadow menu color pwdentry 30;47 #80ffffff #20ffffff std menu color timeout_msg 37;40 #80ffffff #00000000 std menu color timeout 1;37;40 #c0ffffff #00000000 std + menu color help 37;40 #c0ffffff #00000000 std MENU WIDTH 80 @@ -249,6 +262,7 @@ MENU CMDLINEROW 18 MENU ENDROW 24 MENU PASSWORDROW 11 MENU TIMEOUTROW 20 +MENU HELPMSGROW 22 These options control the layout of the menu on the screen. The values above are the defaults. diff --git a/com32/modules/menu.h b/com32/modules/menu.h index c15b84d5..5c15b396 100644 --- a/com32/modules/menu.h +++ b/com32/modules/menu.h @@ -34,6 +34,7 @@ struct menu_entry { char *label; char *cmdline; char *passwd; + char *helptext; unsigned char hotkey; }; diff --git a/com32/modules/menumain.c b/com32/modules/menumain.c index d661dbf6..e44207d1 100644 --- a/com32/modules/menumain.c +++ b/com32/modules/menumain.c @@ -76,6 +76,7 @@ static const struct color_table default_color_table[] = { { "pwdentry", "30;47", 0x80ffffff, 0x20ffffff, SHADOW_NORMAL }, { "timeout_msg", "37;40", 0x80ffffff, 0x00000000, SHADOW_NORMAL }, { "timeout", "1;37;40", 0xc0ffffff, 0x00000000, SHADOW_NORMAL }, + { "help", "37;40", 0xc0ffffff, 0x00000000, SHADOW_NORMAL }, }; #define NCOLORS (sizeof default_color_table/sizeof(struct color_table)) @@ -90,6 +91,7 @@ struct menu_parameter mparm[] = { { "endrow", -1 }, { "passwordrow", 11 }, { "timeoutrow", 20 }, + { "helpmsgrow", 22 }, { NULL, 0 } }; @@ -102,6 +104,7 @@ struct menu_parameter mparm[] = { #define END_ROW mparm[6].value #define PASSWD_ROW mparm[7].value #define TIMEOUT_ROW mparm[8].value +#define HELPMSG_ROW mparm[9].value static void install_default_color_table(void) @@ -397,7 +400,6 @@ draw_menu(int sel, int top, int edit_line) tabmsg = messages[MSG_NOTAB].msg; printf("\1#08\033[%d;1H%s", TABMSG_ROW, pad_line(tabmsg, 1, WIDTH)); - printf("\1#00\033[%d;1H", END_ROW); } @@ -407,6 +409,41 @@ clear_screen(void) fputs("\033e\033%@\033)0\033(B\1#00\033[?25l\033[2J", stdout); } +static void +display_help(const char *text) +{ + int row; + const char *p; + + if (!text) { + text = ""; + printf("\1#00\033[%d;1H", HELPMSG_ROW); + } else { + printf("\1#16\033[%d;1H", HELPMSG_ROW); + } + + for (p = text, row = HELPMSG_ROW; *p && row < END_ROW; p++) { + switch (*p) { + case '\r': + case '\f': + case '\v': + case '\033': + break; + case '\n': + printf("\033[K\033[%d;1H", ++row); + break; + default: + putchar(*p); + } + } + + fputs("\033[K", stdout); + + while (row < END_ROW) { + printf("\033[K\033[%d;1H", ++row); + } +} + static const char * edit_cmdline(char *input, int top) { @@ -620,9 +657,11 @@ run_menu(void) if ( top != prev_top ) { draw_menu(entry, top, 1); + display_help(menu_entries[entry].helptext); } else if ( entry != prev_entry ) { draw_row(prev_entry-top+4, entry, top, 0, 0); draw_row(entry-top+4, entry, top, 0, 0); + display_help(menu_entries[entry].helptext); } prev_entry = entry; prev_top = top; @@ -767,8 +806,9 @@ run_menu(void) clear_screen(); draw_menu(-1, top, 0); } else { - /* Erase [Tab] message */ + /* Erase [Tab] message and help text*/ printf("\033[%d;1H\1#00\033[K", TABMSG_ROW); + display_help(NULL); } if ( ok ) { diff --git a/com32/modules/readconfig.c b/com32/modules/readconfig.c index 0fa5a6aa..cf180bd9 100644 --- a/com32/modules/readconfig.c +++ b/com32/modules/readconfig.c @@ -154,6 +154,7 @@ struct labeldata { char *append; char *menulabel; char *passwd; + char *helptext; unsigned int ipappend; unsigned int menuhide; unsigned int menudefault; @@ -171,6 +172,7 @@ record(struct labeldata *ld, char *append) me->displayname = ld->menulabel ? ld->menulabel : ld->label; me->label = ld->label; me->passwd = ld->passwd; + me->helptext = ld->helptext; me->hotkey = 0; if ( ld->menulabel ) { @@ -545,14 +547,34 @@ static void parse_config_file(FILE *f) } } } else if ( looking_at(p, "text") ) { + enum text_cmd { + TEXT_UNKNOWN, + TEXT_HELP + } cmd = TEXT_UNKNOWN; + int len = ld.helptext ? strlen(ld.helptext) : 0; + int xlen; + p = skipspace(p+4); - /* p points to the TEXT command */ + if (looking_at(p, "help")) + cmd = TEXT_HELP; while ( fgets(line, sizeof line, f) ) { p = skipspace(line); if (looking_at(p, "endtext")) break; + + xlen = strlen(line); + + switch (cmd) { + case TEXT_UNKNOWN: + break; + case TEXT_HELP: + ld.helptext = realloc(ld.helptext, len+xlen+1); + memcpy(ld.helptext+len, line, xlen+1); + len += xlen; + break; + } } } else if ( looking_at(p, "append") ) { char *a = strdup(skipspace(p+6)); @@ -569,6 +591,7 @@ static void parse_config_file(FILE *f) ld.passwd = NULL; ld.append = NULL; ld.menulabel = NULL; + ld.helptext = NULL; ld.ipappend = ipappend; ld.menudefault = ld.menuhide = 0; } else if ( (ep = is_kernel_type(p, &type)) ) { |