[syslinux:pathbased] MENU IMMEDIATE: hotkeys which do not require Enter
syslinux-bot for H. Peter Anvin
hpa at linux.intel.com
Thu May 27 18:24:20 PDT 2010
Commit-ID: 4d66117c87409691ddf1501c17d1642040414a7c
Gitweb: http://syslinux.zytor.com/commit/4d66117c87409691ddf1501c17d1642040414a7c
Author: H. Peter Anvin <hpa at linux.intel.com>
AuthorDate: Thu, 27 May 2010 18:22:21 -0700
Committer: H. Peter Anvin <hpa at linux.intel.com>
CommitDate: Thu, 27 May 2010 18:22:21 -0700
MENU IMMEDIATE: hotkeys which do not require Enter
The normal behavior for a hotkey is to jump to a specific menu entry.
With MENU IMMEDIATE, it activates the menu entry as well.
Signed-off-by: H. Peter Anvin <hpa at linux.intel.com>
---
com32/menu/menu.h | 2 ++
com32/menu/menumain.c | 22 ++++++++++++++++------
com32/menu/readconfig.c | 13 +++++++++++++
3 files changed, 31 insertions(+), 6 deletions(-)
diff --git a/com32/menu/menu.h b/com32/menu/menu.h
index 1e596e1..63e1859 100644
--- a/com32/menu/menu.h
+++ b/com32/menu/menu.h
@@ -63,6 +63,7 @@ struct menu_entry {
int entry; /* Entry number inside menu */
enum menu_action action;
unsigned char hotkey;
+ bool immediate; /* Hotkey action does not require Enter */
bool save; /* Save this entry if selected */
};
@@ -156,6 +157,7 @@ struct menu {
int timeout;
bool allowedit;
+ bool immediate; /* MENU IMMEDIATE default for this menu */
bool save; /* MENU SAVE default for this menu */
int curentry;
diff --git a/com32/menu/menumain.c b/com32/menu/menumain.c
index 0c39264..b04c70b 100644
--- a/com32/menu/menumain.c
+++ b/com32/menu/menumain.c
@@ -754,6 +754,7 @@ static const char *run_menu(void)
const char *cmdline = NULL;
volatile clock_t key_timeout, timeout_left, this_timeout;
const struct menu_entry *me;
+ bool hotkey = false;
/* Note: for both key_timeout and timeout == 0 means no limit */
timeout_left = key_timeout = cm->timeout;
@@ -853,15 +854,23 @@ static const char *run_menu(void)
to_clear = 0;
}
- this_timeout = min(min(key_timeout, timeout_left), (clock_t) CLK_TCK);
- key = mygetkey(this_timeout);
+ if (hotkey && me->immediate) {
+ /* If the hotkey was flagged immediate, simulate pressing ENTER */
+ key = KEY_ENTER;
+ } else {
+ this_timeout = min(min(key_timeout, timeout_left),
+ (clock_t) CLK_TCK);
+ key = mygetkey(this_timeout);
- if (key != KEY_NONE) {
- timeout_left = key_timeout;
- if (to_clear)
- printf("\033[%d;1H\1#0\033[K", TIMEOUT_ROW);
+ if (key != KEY_NONE) {
+ timeout_left = key_timeout;
+ if (to_clear)
+ printf("\033[%d;1H\1#0\033[K", TIMEOUT_ROW);
+ }
}
+ hotkey = false;
+
switch (key) {
case KEY_NONE: /* Timeout */
/* This is somewhat hacky, but this at least lets the user
@@ -1072,6 +1081,7 @@ static const char *run_menu(void)
key_timeout = 0;
entry = cm->menu_hotkeys[key]->entry;
/* Should we commit at this point? */
+ hotkey = true;
}
}
break;
diff --git a/com32/menu/readconfig.c b/com32/menu/readconfig.c
index c8215a0..5685e6f 100644
--- a/com32/menu/readconfig.c
+++ b/com32/menu/readconfig.c
@@ -172,6 +172,7 @@ static struct menu *new_menu(struct menu *parent,
m->allowedit = parent->allowedit;
m->timeout = parent->timeout;
m->save = parent->save;
+ m->immediate = parent->immediate;
m->ontimeout = refstr_get(parent->ontimeout);
m->onerror = refstr_get(parent->onerror);
@@ -219,6 +220,7 @@ struct labeldata {
unsigned int menuindent;
enum menu_action action;
int save;
+ int immediate;
struct menu *submenu;
};
@@ -304,6 +306,7 @@ static void record(struct menu *m, struct labeldata *ld, const char *append)
me->hotkey = 0;
me->action = ld->action ? ld->action : MA_CMD;
me->save = ld->save ? (ld->save > 0) : m->save;
+ me->immediate = ld->immediate ? (ld->immediate > 0) : m->immediate;
if (ld->menuindent) {
const char *dn;
@@ -674,6 +677,16 @@ static void parse_config_file(FILE * f)
ld.save = -1;
else
m->save = false;
+ } else if (looking_at(p, "immediate")) {
+ if (ld.label)
+ ld.immediate = 1;
+ else
+ m->immediate = true;
+ } else if (looking_at(p, "noimmediate")) {
+ if (ld.label)
+ ld.immediate = -1;
+ else
+ m->immediate = false;
} else if (looking_at(p, "onerror")) {
refstr_put(m->onerror);
m->onerror = refstrdup(skipspace(p + 7));
More information about the Syslinux-commits
mailing list