Allow customization of the menu layout.
authorhpa <hpa>
Fri, 26 Aug 2005 00:51:49 +0000 (00:51 +0000)
committerhpa <hpa>
Fri, 26 Aug 2005 00:51:49 +0000 (00:51 +0000)
README.menu
com32/modules/menu.c
com32/modules/menu.h
com32/modules/readconfig.c

index 26a07b1..30561b4 100644 (file)
@@ -108,6 +108,19 @@ MENU MASTER PASSWD passwd
        work.
 
 
+MENU WIDTH 80
+MENU MARGIN 10
+MENU PASSWORDMARGIN 3
+MENU ROWS 12
+MENU TABMSGROW 18
+MENU CMDLINEROW 20
+MENU ENDROW 24
+MENU PASSWORDROW 11
+
+       These options control the layout of the menu on the screen.
+       The values above are the defaults.
+
+
 The menu system honours the TIMEOUT command; if TIMEOUT is specified
 it will execute the ONTIMEOUT command if one exists, otherwise it will
 pick the default menu option.
index c403239..3b900ac 100644 (file)
@@ -77,14 +77,26 @@ static const struct menu_attrib default_attrib = {
 
 static const struct menu_attrib *menu_attrib = &default_attrib;
 
-#define WIDTH          80
-#define MARGIN         10
-#define PASSWD_MARGIN  3
-#define MENU_ROWS      12
-#define TABMSG_ROW     18
-#define CMDLINE_ROW    20
-#define END_ROW                24
-#define PASSWD_ROW     11
+struct menu_parameter mparm[] = {
+  { "width", 80 },
+  { "margin", 10 },
+  { "passwordmargin", 3 },
+  { "rows", 12 },
+  { "tabmsgrow", 18 },
+  { "cmdlinerow", 20 },
+  { "endrow", 24 },
+  { "passwordrow", 11 },
+  { NULL, 0 }
+};
+
+#define WIDTH          mparm[0].value
+#define MARGIN         mparm[1].value
+#define PASSWD_MARGIN  mparm[2].value
+#define MENU_ROWS      mparm[3].value
+#define TABMSG_ROW     mparm[4].value
+#define CMDLINE_ROW    mparm[5].value
+#define END_ROW                mparm[6].value
+#define PASSWD_ROW     mparm[7].value
 
 static char *
 pad_line(const char *text, int align, int width)
index 02df13a..091a133 100644 (file)
@@ -1,7 +1,7 @@
 #ident "$Id$"
 /* ----------------------------------------------------------------------- *
  *   
- *   Copyright 2004 H. Peter Anvin - All Rights Reserved
+ *   Copyright 2004-2005 H. Peter Anvin - All Rights Reserved
  *
  *   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
@@ -34,6 +34,13 @@ struct menu_entry {
 extern struct menu_entry menu_entries[];
 extern struct menu_entry *menu_hotkeys[256];
 
+struct menu_parameter {
+  const char *name;
+  int value;
+};
+
+extern struct menu_parameter mparm[];
+
 extern int nentries;
 extern int defentry;
 extern int allowedit;
index c61a1e5..c8c57c0 100644 (file)
@@ -224,11 +224,19 @@ void parse_config(const char *filename)
        ld.passwd = strdup(skipspace(p+6));
       } else if ( looking_at(p, "master") ) {
        p = skipspace(p+6);
-       if ( looking_at (p, "passwd") ) {
+       if ( looking_at(p, "passwd") ) {
          menu_master_passwd = strdup(skipspace(p+6));
        }
       } else {
-       /* Unknown, ignore for now */
+       /* Unknown, check for parameters */
+       struct menu_parameter *pp;
+       for ( pp = mparm ; pp->name ; pp++ ) {
+         if ( looking_at(p, pp->name) ) {
+           p = skipspace(p+strlen(pp->name));
+           pp->value = atoi(p);
+           break;
+         }
+       }
       }
     } else if ( looking_at(p, "append") ) {
       char *a = strdup(skipspace(p+6));