diff options
| author | hpa <hpa> | 2004-12-21 06:30:54 +0000 |
|---|---|---|
| committer | hpa <hpa> | 2004-12-21 06:30:54 +0000 |
| commit | 525bbe0393f388e065447044b421b84b2e187c8c (patch) | |
| tree | a97ebcf34575dcfedacce127b92e5a062bcd7ea5 /com32/modules | |
| parent | abf1b805231a7cd01a249c67413e7c1e3152b72e (diff) | |
| download | syslinux-2.20-pre11.tar.gz | |
I think the menu system actually works now...syslinux-2.20-pre11
Diffstat (limited to 'com32/modules')
| -rw-r--r-- | com32/modules/menu.c | 18 | ||||
| -rw-r--r-- | com32/modules/menu.h | 4 | ||||
| -rw-r--r-- | com32/modules/readconfig.c | 38 |
3 files changed, 41 insertions, 19 deletions
diff --git a/com32/modules/menu.c b/com32/modules/menu.c index e3dace2f..c9794c24 100644 --- a/com32/modules/menu.c +++ b/com32/modules/menu.c @@ -131,6 +131,8 @@ void draw_menu(int sel, int top) if ( allowedit ) printf("%s\033[%d;1H%s", menu_attrib->tabmsg, TABMSG_ROW, pad_line("Press [Tab] to edit options", 1, WIDTH)); + + printf("%s\033[%d;1H", menu_attrib->screen, END_ROW); } char *edit_cmdline(char *input) @@ -176,7 +178,7 @@ char *edit_cmdline(char *input) case KEY_CTRL('U'): if ( len ) { len = 0; - cmdline[len] = 0; + cmdline[len] = '\0'; redraw = 1; } break; @@ -187,6 +189,7 @@ char *edit_cmdline(char *input) len--; wasbs = wasbs || (cmdline[len-1] <= ' '); } + cmdline[len] = '\0'; redraw = 1; } break; @@ -207,11 +210,9 @@ const char *run_menu(void) int done = 0; int entry = defentry; int top = 0; + int clear = 1; char *cmdline; - /* Start with a clear screen */ - printf("%s\033[2J", menu_attrib->screen); - while ( !done ) { if ( entry < 0 ) entry = 0; @@ -223,6 +224,11 @@ const char *run_menu(void) else if ( top > entry ) top = entry; + /* Start with a clear screen */ + if ( clear ) + printf("%s\033[2J", menu_attrib->screen); + clear = 0; + draw_menu(entry, top); key = get_key(stdin); @@ -266,6 +272,8 @@ const char *run_menu(void) cmdline = edit_cmdline(menu_entries[entry].cmdline); if ( cmdline ) return cmdline; + else + clear = 1; } break; case KEY_CTRL('C'): /* Ctrl-C */ @@ -278,7 +286,7 @@ const char *run_menu(void) } /* Return the label name so localboot and ipappend work */ - return menu_entries[entry].displayname; + return menu_entries[entry].label; } diff --git a/com32/modules/menu.h b/com32/modules/menu.h index e892a124..4766a395 100644 --- a/com32/modules/menu.h +++ b/com32/modules/menu.h @@ -14,7 +14,7 @@ /* * menu.h * - * Header file for the menu project + * Header file for the simple menu system */ #ifndef MENU_H @@ -22,7 +22,9 @@ struct menu_entry { char *displayname; + char *label; char *cmdline; + int flags; }; #define MAX_CMDLINE_LEN 256 diff --git a/com32/modules/readconfig.c b/com32/modules/readconfig.c index 39d3635d..eb64d6ae 100644 --- a/com32/modules/readconfig.c +++ b/com32/modules/readconfig.c @@ -111,7 +111,10 @@ struct labeldata { char *label; char *kernel; char *append; + char *menulabel; unsigned int ipappend; + unsigned int menuhide; + unsigned int menudefault; }; static void record(struct labeldata *ld, char *append) @@ -121,7 +124,9 @@ static void record(struct labeldata *ld, char *append) if ( ld->label ) { char *a, *s; - menu_entries[nentries].displayname = ld->label; + menu_entries[nentries].displayname = + ld->menulabel ? ld->menulabel : ld->label; + menu_entries[nentries].label = ld->label; ipp = ipoptions; *ipp = '\0'; @@ -136,14 +141,16 @@ static void record(struct labeldata *ld, char *append) s = a[0] ? " " : ""; asprintf(&menu_entries[nentries].cmdline, "%s%s%s%s", ld->kernel, ipoptions, s, a); - printf("displayname: %s\n", menu_entries[nentries].displayname); - printf("cmdline: %s\n", menu_entries[nentries].cmdline); - ld->label = NULL; free(ld->kernel); if ( ld->append ) free(ld->append); - nentries++; + + if ( !ld->menuhide ) { + if ( ld->menudefault ) + defentry = nentries; + nentries++; + } } } @@ -172,15 +179,19 @@ void parse_config(const char *filename) *p = '\0'; p = skipspace(line); - printf("> %s\n", p); if ( looking_at(p, "menu") ) { - p = skipspace(line+4); - + p = skipspace(p+4); + if ( looking_at(p, "title") ) { menu_title = strdup(skipspace(p+5)); + } else if ( looking_at(p, "label") ) { + if ( ld.label ) + ld.menulabel = strdup(skipspace(p+5)); } else if ( looking_at(p, "default") ) { - defentry = atoi(skipspace(p+7)); + ld.menudefault = 1; + } else if ( looking_at(p, "hide") ) { + ld.menuhide = 1; } else { /* Unknown, ignore for now */ } @@ -193,10 +204,11 @@ void parse_config(const char *filename) } else if ( looking_at(p, "label") ) { p = skipspace(p+5); record(&ld, append); - ld.label = strdup(p); - ld.kernel = strdup(p); - ld.append = NULL; - ld.ipappend = 0; + ld.label = strdup(p); + ld.kernel = strdup(p); + ld.append = NULL; + ld.menulabel = NULL; + ld.ipappend = ld.menudefault = ld.menuhide = 0; } else if ( looking_at(p, "kernel") ) { if ( ld.label ) { free(ld.kernel); |
