summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2007-02-27 22:38:10 -0800
committerH. Peter Anvin <hpa@zytor.com>2007-02-27 22:38:10 -0800
commitd173045be2c578565e2e50719c510bb2f38b0d9a (patch)
treecf3cace2e71aed5dfd708c17ddbcc912094f5d75
parentbdec516cbccd4a88377f1df0602a65cc91a03c4d (diff)
downloadsyslinux-d173045be2c578565e2e50719c510bb2f38b0d9a.tar.gz
Support customization of menu messages.
-rw-r--r--NEWS2
-rw-r--r--README.menu16
-rw-r--r--com32/modules/menu.h3
-rw-r--r--com32/modules/menumain.c31
-rw-r--r--com32/modules/readconfig.c26
5 files changed, 69 insertions, 9 deletions
diff --git a/NEWS b/NEWS
index 31847f19..3b17d5b4 100644
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,8 @@ Changes in 3.40:
* It is now supported to load a different configuration file
with the CONFIG keyword.
* Fix API call 0x0019 (Read Disk.)
+ * MENU AUTOBOOT, MENU TABMSG, MENU PASSPROMPT allows
+ internationalization of menu messages.
Changes in 3.36:
* MEMDISK: Disable EDD by default on floppy disks. EDD can be
diff --git a/README.menu b/README.menu
index fe4f9091..efa79891 100644
--- a/README.menu
+++ b/README.menu
@@ -121,6 +121,22 @@ MENU INCLUDE filename
command, so any labels defined in it are unavailable.
+MENU AUTOBOOT message
+
+ Replaces the message "Automatic boot in # seconds". The
+ symbol # is replaced with the number of seconds remaining.
+
+
+MENU TABMSG message
+
+ Replaces the message "Press [Tab] to edit options".
+
+
+MENU PASSPROMPT message
+
+ Replaces the message "Password required".
+
+
MENU COLOR element ansi foreground background shadow
Sets the color of element "element" to the specified color
diff --git a/com32/modules/menu.h b/com32/modules/menu.h
index acdbb348..0a5808d5 100644
--- a/com32/modules/menu.h
+++ b/com32/modules/menu.h
@@ -81,6 +81,9 @@ extern char *menu_title;
extern char *ontimeout;
extern char *onerror;
extern char *menu_master_passwd;
+extern char *menu_tab_msg;
+extern char *menu_autoboot_msg;
+extern char *menu_passprompt_msg;
extern char *menu_background;
diff --git a/com32/modules/menumain.c b/com32/modules/menumain.c
index 14e0af2c..7c96a706 100644
--- a/com32/modules/menumain.c
+++ b/com32/modules/menumain.c
@@ -279,7 +279,6 @@ static int mygetkey(clock_t timeout)
static int
ask_passwd(const char *menu_entry)
{
- static const char title[] = "Password required";
char user_passwd[WIDTH], *p;
int done;
int key;
@@ -298,8 +297,8 @@ ask_passwd(const char *menu_entry)
putchar('q');
printf("j\017\033[%d;%dH\1#12 %s \033[%d;%dH\1#13",
- PASSWD_ROW, (WIDTH-((int)sizeof(title)+1))/2,
- title, PASSWD_ROW+1, PASSWD_MARGIN+3);
+ PASSWD_ROW, (WIDTH-(strlen(menu_passprompt_msg)+2))/2,
+ menu_passprompt_msg, PASSWD_ROW+1, PASSWD_MARGIN+3);
/* Actually allow user to type a password, then compare to the SHA1 */
done = 0;
@@ -392,8 +391,7 @@ draw_menu(int sel, int top, int edit_line)
fputs("j\017", stdout);
if ( edit_line && allowedit && !menu_master_passwd )
- printf("\1#08\033[%d;1H%s", TABMSG_ROW,
- pad_line("Press [Tab] to edit options", 1, WIDTH));
+ printf("\1#08\033[%d;1H%s", TABMSG_ROW, pad_line(menu_tab_msg, 1, WIDTH));
printf("\1#00\033[%d;1H", END_ROW);
}
@@ -629,10 +627,27 @@ run_menu(void)
key_timeout = 0;
if ( key_timeout ) {
+ char buf[256];
int tol = timeout_left/CLK_TCK;
- int nc = snprintf(NULL, 0, " Automatic boot in %d seconds ", tol);
- printf("\033[%d;%dH\1#14 Automatic boot in \1#15%d\1#14 seconds ",
- TIMEOUT_ROW, 1+((WIDTH-nc)>>1), tol);
+ int nc = 0, nnc;
+ const char *tp = menu_autoboot_msg;
+ char tc;
+ char *tq = buf;
+
+ while ((tq-buf) < (sizeof buf-16) && (tc = *tp)) {
+ if (tc == '#') {
+ nnc = sprintf(tq, "\1#15%d\1#14", tol);
+ tq += nnc;
+ nc += nnc-8; /* 8 formatting characters */
+ } else {
+ *tq++ = tc;
+ nc++;
+ }
+ tp++;
+ }
+ *tq = '\0';
+
+ printf("\033[%d;%dH\1#14 %s ", TIMEOUT_ROW, 1+((WIDTH-nc)>>1), buf);
to_clear = 1;
} else {
to_clear = 0;
diff --git a/com32/modules/readconfig.c b/com32/modules/readconfig.c
index 0f9b7c60..5489c72d 100644
--- a/com32/modules/readconfig.c
+++ b/com32/modules/readconfig.c
@@ -32,12 +32,16 @@ int timeout = 0;
int shiftkey = 0; /* Only display menu if shift key pressed */
long long totaltimeout = 0;
-char *menu_title = "";
+char *menu_title = NULL;
char *ontimeout = NULL;
char *onerror = NULL;
char *menu_master_passwd = NULL;
+char *menu_tab_msg;
+char *menu_autoboot_msg;
+char *menu_passprompt_msg;
+
char *menu_background = NULL;
struct menu_entry menu_entries[MAX_ENTRIES];
@@ -456,6 +460,15 @@ static void parse_config_file(FILE *f)
if (menu_background)
free(menu_background);
menu_background = dup_word(&p);
+ } else if ( (ep = looking_at(p, "autoboot")) ) {
+ free(menu_autoboot_msg);
+ menu_autoboot_msg = strdup(skipspace(ep));
+ } else if ( (ep = looking_at(p, "tabmsg")) ) {
+ free(menu_tab_msg);
+ menu_tab_msg = strdup(skipspace(ep));
+ } else if ( (ep = looking_at(p, "passprompt")) ) {
+ free(menu_passprompt_msg);
+ menu_passprompt_msg = strdup(skipspace(ep));
} else if ((ep = looking_at(p, "color")) ||
(ep = looking_at(p, "colour"))) {
int i;
@@ -576,8 +589,19 @@ void parse_configs(char **argv)
{
const char *filename;
+ /* Initialize defaults */
+
+ menu_title = strdup("");
+ menu_tab_msg = strdup("Press [Tab] to edit options");
+ menu_autoboot_msg = strdup("Automatic boot in # sections");
+ menu_passprompt_msg = strdup("Password required");
+
+ /* Other initialization */
+
get_ipappend();
+ /* Actually process the files */
+
if ( !*argv ) {
parse_one_config("~");
} else {