summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2007-11-21 12:29:32 -0800
committerH. Peter Anvin <hpa@zytor.com>2007-11-21 12:29:32 -0800
commitebde32062eb97d6315b0a0d850b8054cf4dfdfca (patch)
tree05a73e7dfafdc9e97e58cee5e9e30ff03a3b0332
parente32ef7ef4c5e74cd9f44c016e1e92e2033bd6263 (diff)
downloadsyslinux-ebde32062eb97d6315b0a0d850b8054cf4dfdfca.tar.gz
Add "menu separator", "menu indent", "menu disabled"
A few more options for the menu: "menu separator", "menu indent", "menu disabled".
-rw-r--r--com32/modules/menu.h1
-rw-r--r--com32/modules/menumain.c25
-rw-r--r--com32/modules/readconfig.c43
3 files changed, 61 insertions, 8 deletions
diff --git a/com32/modules/menu.h b/com32/modules/menu.h
index 78382ef5..c7f542d3 100644
--- a/com32/modules/menu.h
+++ b/com32/modules/menu.h
@@ -37,6 +37,7 @@ struct menu_entry {
char *passwd;
char *helptext;
unsigned char hotkey;
+ unsigned char disabled;
};
enum kernel_type {
diff --git a/com32/modules/menumain.c b/com32/modules/menumain.c
index b28371ef..23248a64 100644
--- a/com32/modules/menumain.c
+++ b/com32/modules/menumain.c
@@ -892,10 +892,15 @@ run_menu(void)
}
while ( !done ) {
- if ( entry < 0 )
+ if ( entry <= 0 ) {
entry = 0;
- else if ( entry >= nentries )
+ while ( entry < nentries && menu_entries[entry].disabled ) entry++;
+ }
+
+ if ( entry >= nentries ) {
entry = nentries-1;
+ while ( entry > 0 && menu_entries[entry].disabled ) entry--;
+ }
if ( top < 0 || top < entry-MENU_ROWS+1 )
top = max(0, entry-MENU_ROWS+1);
@@ -978,20 +983,28 @@ run_menu(void)
case KEY_UP:
case KEY_CTRL('P'):
- if ( entry > 0 ) {
- entry--;
+ while ( entry > 0 && entry-- && menu_entries[entry].disabled ) {
if ( entry < top )
top -= MENU_ROWS;
}
+
+ if ( entry == 0 ) {
+ while ( menu_entries[entry].disabled )
+ entry++;
+ }
break;
case KEY_DOWN:
case KEY_CTRL('N'):
- if ( entry < nentries-1 ) {
- entry++;
+ while ( entry < nentries-1 && entry++ && menu_entries[entry].disabled ) {
if ( entry >= top+MENU_ROWS )
top += MENU_ROWS;
}
+
+ if ( entry == nentries-1 ) {
+ while ( menu_entries[entry].disabled )
+ entry--;
+ }
break;
case KEY_PGUP:
diff --git a/com32/modules/readconfig.c b/com32/modules/readconfig.c
index 89c09622..a3b41115 100644
--- a/com32/modules/readconfig.c
+++ b/com32/modules/readconfig.c
@@ -161,6 +161,9 @@ struct labeldata {
unsigned int ipappend;
unsigned int menuhide;
unsigned int menudefault;
+ unsigned int menuseparator;
+ unsigned int menudisabled;
+ unsigned int menuindent;
};
static void
@@ -177,6 +180,14 @@ record(struct labeldata *ld, char *append)
me->passwd = ld->passwd;
me->helptext = ld->helptext;
me->hotkey = 0;
+ me->disabled = 0;
+
+ if ( ld->menuindent ) {
+ char *n = (char *)malloc(ld->menuindent + strlen(me->displayname) + 1);
+ memset(n, 32, ld->menuindent);
+ strcpy(n + ld->menuindent, me->displayname);
+ me->displayname = n;
+ }
if ( ld->menulabel ) {
unsigned char *p = (unsigned char *)strchr(ld->menulabel, '^');
@@ -207,6 +218,20 @@ record(struct labeldata *ld, char *append)
kernel_types[ld->type], ld->kernel, s, a, ipoptions);
}
+ if ( ld->menuseparator )
+ me->displayname = "";
+
+ if ( ld->menuseparator || ld->menudisabled ) {
+ me->label = NULL;
+ me->passwd = NULL;
+ me->disabled = 1;
+
+ if ( me->cmdline )
+ free(me->cmdline);
+
+ me->cmdline = NULL;
+ }
+
ld->label = NULL;
ld->passwd = NULL;
@@ -222,7 +247,7 @@ record(struct labeldata *ld, char *append)
if ( me->hotkey )
menu_hotkeys[me->hotkey] = me;
- if ( ld->menudefault )
+ if ( ld->menudefault && !ld->menudisabled && !ld->menuseparator )
defentry = nentries;
nentries++;
@@ -598,6 +623,18 @@ static void parse_config_file(FILE *f)
}
}
set_msg_colors_global(fg_mask, bg_mask, shadow);
+ } else if ( looking_at(p, "separator") ) {
+ record(&ld, append);
+ memset(&ld, 0, sizeof(struct labeldata));
+ ld.label = "";
+ ld.menuseparator = 1;
+ record(&ld, append);
+ memset(&ld, 0, sizeof(struct labeldata));
+ } else if ( looking_at(p, "disable") ||
+ looking_at(p, "disabled")) {
+ ld.menudisabled = 1;
+ } else if ( looking_at(p, "indent") ) {
+ ld.menuindent = atoi(skipspace(p+6));
} else {
/* Unknown, check for layout parameters */
struct menu_parameter *pp;
@@ -674,7 +711,8 @@ static void parse_config_file(FILE *f)
ld.menulabel = NULL;
ld.helptext = NULL;
ld.ipappend = ipappend;
- ld.menudefault = ld.menuhide = 0;
+ ld.menudefault = ld.menuhide = ld.menuseparator =
+ ld.menudisabled = ld.menuindent = 0;
} else if ( (ep = is_kernel_type(p, &type)) ) {
if ( ld.label ) {
free(ld.kernel);
@@ -731,6 +769,7 @@ void parse_configs(char **argv)
/* Other initialization */
get_ipappend();
+ memset(&ld, 0, sizeof(struct labeldata));
/* Actually process the files */