summaryrefslogtreecommitdiff
path: root/com32
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2008-02-19 18:21:08 -0800
committerH. Peter Anvin <hpa@zytor.com>2008-02-19 18:21:08 -0800
commitc758029be533c05d674251f204ca368be5d2c67f (patch)
tree1ed6a7e9de91d3fd381ec787e16da7e2a0b5f4e0 /com32
parentc62e26d7dd4d579e4a92e1ff836fb43f944ceb82 (diff)
downloadsyslinux-c758029be533c05d674251f204ca368be5d2c67f.tar.gz
simple menu: remember the cursor position on a per-menu basis
For each menu, remember what the current position of the cursor and the scroll is.
Diffstat (limited to 'com32')
-rw-r--r--com32/menu/menu.h3
-rw-r--r--com32/menu/menumain.c17
-rw-r--r--com32/menu/readconfig.c2
3 files changed, 16 insertions, 6 deletions
diff --git a/com32/menu/menu.h b/com32/menu/menu.h
index 638fece3..5aeb48f6 100644
--- a/com32/menu/menu.h
+++ b/com32/menu/menu.h
@@ -148,6 +148,9 @@ struct menu {
int allowedit;
int timeout;
+ int curentry;
+ int curtop;
+
const char *title;
const char *ontimeout;
const char *onerror;
diff --git a/com32/menu/menumain.c b/com32/menu/menumain.c
index f1398c84..d5631982 100644
--- a/com32/menu/menumain.c
+++ b/com32/menu/menumain.c
@@ -31,7 +31,7 @@
#include "menu.h"
/* The symbol "cm" always refers to the current menu across this file... */
-static const struct menu *cm;
+static struct menu *cm;
const struct menu_parameter mparm[NPARAMS] = {
[P_WIDTH] = { "width", 0 },
@@ -698,8 +698,10 @@ run_menu(void)
{
int key;
int done = 0;
- volatile int entry = cm->defentry, prev_entry = -1;
- int top = 0, prev_top = -1;
+ volatile int entry = cm->curentry;
+ int prev_entry = -1;
+ volatile int top = cm->curtop;
+ int prev_top = -1;
int clear = 1, to_clear;
const char *cmdline = NULL;
volatile clock_t key_timeout, timeout_left, this_timeout;
@@ -787,6 +789,8 @@ run_menu(void)
}
prev_entry = entry; prev_top = top;
+ cm->curentry = entry;
+ cm->curtop = top;
/* Cursor movement cancels timeout */
if ( entry != cm->defentry )
@@ -850,8 +854,8 @@ run_menu(void)
done = 0;
clear = 2;
cm = me->submenu;
- entry = cm->defentry;
- top = 0;
+ entry = cm->curentry;
+ top = cm->curtop;
break;
case MA_QUIT:
/* Quit menu system */
@@ -978,7 +982,8 @@ run_menu(void)
if ( cm->parent ) {
cm = cm->parent;
clear = 2;
- entry = top = 0;
+ entry = cm->curentry;
+ top = cm->curtop;
} else if ( cm->allowedit ) {
done = 1;
clear = 1;
diff --git a/com32/menu/readconfig.c b/com32/menu/readconfig.c
index e14e858f..9a0697f3 100644
--- a/com32/menu/readconfig.c
+++ b/com32/menu/readconfig.c
@@ -928,6 +928,8 @@ void parse_configs(char **argv)
resolve_gotos();
for (m = menu_list; m; m = m->next) {
+ m->curentry = m->defentry; /* All menus start at their defaults */
+
if ( m->ontimeout )
m->ontimeout = unlabel(m->ontimeout);
if ( m->onerror )