aboutsummaryrefslogtreecommitdiffstats
path: root/com32/menu
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@linux.intel.com>2011-04-11 14:59:45 -0700
committerH. Peter Anvin <hpa@linux.intel.com>2011-04-11 15:06:38 -0700
commita8e74b2834664543166744cf0832e1d6db36347f (patch)
tree2c22b842d476d69cbeeb95dbfe9df433c8fa60b4 /com32/menu
parent868c474546ba68e9e448734e1833f873fd50ec0a (diff)
downloadsyslinux-a8e74b2834664543166744cf0832e1d6db36347f.tar.gz
syslinux-a8e74b2834664543166744cf0832e1d6db36347f.tar.xz
syslinux-a8e74b2834664543166744cf0832e1d6db36347f.zip
menu: Add "menu hiddenkey" to make terminating menu hidden a command
Use "menu hiddenkey" together with "menu hidden" for a one-keystroke action. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Diffstat (limited to 'com32/menu')
-rw-r--r--com32/menu/menu.h2
-rw-r--r--com32/menu/menumain.c2
-rw-r--r--com32/menu/readconfig.c31
3 files changed, 33 insertions, 2 deletions
diff --git a/com32/menu/menu.h b/com32/menu/menu.h
index 36c5669c..1db4d7c9 100644
--- a/com32/menu/menu.h
+++ b/com32/menu/menu.h
@@ -26,6 +26,7 @@
#include <unistd.h>
#include <colortbl.h>
#include <stdbool.h>
+#include <getkey.h>
#include "refstr.h"
/* #define DEBUG 1 */
@@ -186,6 +187,7 @@ extern int shiftkey;
extern int hiddenmenu;
extern int clearmenu;
extern long long totaltimeout;
+extern const char *hide_key[KEY_MAX];
void parse_configs(char **argv);
int draw_background(const char *filename);
diff --git a/com32/menu/menumain.c b/com32/menu/menumain.c
index 06725f37..df1eb185 100644
--- a/com32/menu/menumain.c
+++ b/com32/menu/menumain.c
@@ -727,7 +727,7 @@ static const char *do_hidden_menu(void)
key = mygetkey(this_timeout);
if (key != KEY_NONE)
- return NULL; /* Key pressed */
+ return hide_key[key]; /* NULL if no MENU HIDEKEY in effect */
timeout_left -= this_timeout;
}
diff --git a/com32/menu/readconfig.c b/com32/menu/readconfig.c
index f3b0f96d..1d02120c 100644
--- a/com32/menu/readconfig.c
+++ b/com32/menu/readconfig.c
@@ -1,7 +1,7 @@
/* ----------------------------------------------------------------------- *
*
* Copyright 2004-2009 H. Peter Anvin - All Rights Reserved
- * Copyright 2009-2010 Intel Corporation; author: H. Peter Anvin
+ * Copyright 2009-2011 Intel Corporation; author: H. Peter Anvin
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -37,6 +37,7 @@ int shiftkey = 0; /* Only display menu if shift key pressed */
int hiddenmenu = 0;
int clearmenu = 0;
long long totaltimeout = 0;
+const char *hide_key[KEY_MAX];
/* Keep track of global default */
static int has_ui = 0; /* DEFAULT only counts if UI is found */
@@ -141,6 +142,22 @@ static char *looking_at(char *line, const char *kwd)
return my_isspace(*p) ? p : NULL; /* Must be EOL or whitespace */
}
+/* Get a single word into a new refstr; advances the input pointer */
+static char *get_word(char *str, const char **word)
+{
+ char *p = str;
+ char *q;
+
+ while (*p && !my_isspace(*p))
+ p++;
+
+ *word = q = refstr_alloc(p - str + 1);
+ memcpy(q, str, p - str);
+ /* refstr_alloc() already inserted a terminating NUL */
+
+ return p;
+}
+
static struct menu *new_menu(struct menu *parent,
struct menu_entry *parent_entry, const char *label)
{
@@ -703,6 +720,18 @@ static void parse_config_file(FILE * f)
m->menu_background = refdup_word(&p);
} else if ((ep = looking_at(p, "hidden"))) {
hiddenmenu = 1;
+ } else if (looking_at(p, "hiddenkey")) {
+ const char *key_name;
+ int key;
+ p = skipspace(p + 7);
+ p = get_word(p, &key_name);
+ p = skipspace(p);
+ key = key_name_to_code(key_name);
+ refstr_put(key_name);
+ if (key >= 0) {
+ refstr_put(hide_key[key]);
+ hide_key[key] = refstrdup(skipspace(p));
+ }
} else if ((ep = looking_at(p, "clear"))) {
clearmenu = 1;
} else if ((ep = is_message_name(p, &msgnr))) {