aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--com32/menu/menu.h1
-rw-r--r--com32/menu/menumain.c23
-rw-r--r--com32/menu/readconfig.c11
-rw-r--r--doc/menu.doc8
4 files changed, 39 insertions, 4 deletions
diff --git a/com32/menu/menu.h b/com32/menu/menu.h
index d9bbd608..638fece3 100644
--- a/com32/menu/menu.h
+++ b/com32/menu/menu.h
@@ -42,6 +42,7 @@ enum menu_action {
MA_GOTO, /* Go to another menu */
MA_GOTO_UNRES, /* Unresolved go to */
MA_QUIT, /* Quit to CLI */
+ MA_EXIT, /* Exit to higher-level menu */
};
struct menu_entry {
diff --git a/com32/menu/menumain.c b/com32/menu/menumain.c
index 8c1dabf9..f1398c84 100644
--- a/com32/menu/menumain.c
+++ b/com32/menu/menumain.c
@@ -95,12 +95,24 @@ display_entry(const struct menu_entry *entry, const char *attrib,
const char *hotattrib, int width)
{
const char *p = entry->displayname;
- bool is_submenu = (entry->action == MA_SUBMENU || entry->action == MA_GOTO);
+ char marker;
if (!p)
p = "";
- if (is_submenu)
+ switch (entry->action) {
+ case MA_SUBMENU:
+ marker = '>';
+ break;
+ case MA_EXIT:
+ marker = '<';
+ break;
+ default:
+ marker = 0;
+ break;
+ }
+
+ if (marker)
width -= 2;
while ( width ) {
@@ -123,8 +135,10 @@ display_entry(const struct menu_entry *entry, const char *attrib,
}
}
- if (is_submenu)
- fputs(" >", stdout);
+ if (marker) {
+ putchar(' ');
+ putchar(marker);
+ }
}
static void
@@ -832,6 +846,7 @@ run_menu(void)
break;
case MA_SUBMENU:
case MA_GOTO:
+ case MA_EXIT:
done = 0;
clear = 2;
cm = me->submenu;
diff --git a/com32/menu/readconfig.c b/com32/menu/readconfig.c
index 756cb210..e14e858f 100644
--- a/com32/menu/readconfig.c
+++ b/com32/menu/readconfig.c
@@ -180,6 +180,7 @@ struct labeldata {
unsigned int menudisabled;
unsigned int menuindent;
enum menu_action action;
+ struct menu *submenu;
};
/* Menu currently being parsed */
@@ -321,6 +322,11 @@ record(struct menu *m, struct labeldata *ld, const char *append)
me->cmdline = refstr_get(ld->kernel);
break;
+ case MA_GOTO:
+ case MA_EXIT:
+ me->submenu = ld->submenu;
+ break;
+
default:
break;
}
@@ -727,6 +733,11 @@ static void parse_config_file(FILE *f)
refstr_put(ld.kernel);
ld.kernel = refstrdup(skipspace(p+4));
}
+ } else if ( looking_at(p, "exit") ) {
+ if (ld.label && m->parent) {
+ ld.action = MA_EXIT;
+ ld.submenu = m->parent;
+ }
} else if ( looking_at(p, "start") ) {
start_menu = m;
} else {
diff --git a/doc/menu.doc b/doc/menu.doc
index 05407317..fefd92c7 100644
--- a/doc/menu.doc
+++ b/doc/menu.doc
@@ -214,6 +214,14 @@ MENU GOTO tagname
"menu goto .top".
+MENU EXIT
+
+ (Only valid after a label statement inside MENU BEGIN ...
+ MENU END)
+
+ Exit to the next higher menu.
+
+
MENU QUIT
(Only valid after a LABEL statement.)