vesamenu: add MENU RESOLUTION to be able to set nonstandard res
authorH. Peter Anvin <hpa@zytor.com>
Tue, 8 Dec 2009 00:18:09 +0000 (16:18 -0800)
committerH. Peter Anvin <hpa@zytor.com>
Tue, 8 Dec 2009 00:18:09 +0000 (16:18 -0800)
Add a MENU RESOLUTION command to make it possible to set a nonstandard
resolution.  If the nonstandard resolution is unavailable, we revert
to the text mode screen.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
com32/menu/menu.c
com32/menu/menu.h
com32/menu/menumain.c
com32/menu/readconfig.c
com32/menu/vesamenu.c

index 2c069fb..797189b 100644 (file)
@@ -27,8 +27,13 @@ int draw_background(const char *arg)
     return 0;
 }
 
-int main(int argc, char *argv[])
+void set_resolution(int x, int y)
+{
+    (void)x;
+    (void)y;
+}
+
+void start_console(void)
 {
     console_ansi_raw();
-    return menu_main(argc, argv);
 }
index 1d7dee8..0bfc47b 100644 (file)
@@ -181,6 +181,8 @@ extern long long totaltimeout;
 
 void parse_configs(char **argv);
 int draw_background(const char *filename);
+void set_resolution(int x, int y);
+void start_console(void);
 
 static inline int my_isspace(char c)
 {
@@ -192,10 +194,6 @@ unsigned int hexval(char c);
 unsigned int hexval2(const char *p);
 uint32_t parse_argb(char **p);
 
-int menu_main(int argc, char *argv[]);
-void console_prepare(void);
-void console_cleanup(void);
-
 extern const int message_base_color, menu_color_table_size;
 int mygetkey(clock_t timeout);
 int show_message_file(const char *filename, const char *background);
index 82f0018..67deac3 100644 (file)
@@ -1072,7 +1072,7 @@ static const char *run_menu(void)
     return cmdline;
 }
 
-int menu_main(int argc, char *argv[])
+int main(int argc, char *argv[])
 {
     const char *cmdline;
     struct menu *m;
@@ -1081,14 +1081,20 @@ int menu_main(int argc, char *argv[])
 
     (void)argc;
 
+    parse_configs(argv + 1);
+
+    /*
+     * We don't start the console until we have parsed the configuration
+     * file, since the configuration file might impact the console
+     * configuration, e.g. MENU RESOLUTION.
+     */
+    start_console();
     if (getscreensize(1, &rows, &cols)) {
        /* Unknown screen size? */
        rows = 24;
        cols = 80;
     }
 
-    parse_configs(argv + 1);
-
     /* Some postprocessing for all menus */
     for (m = menu_list; m; m = m->next) {
        if (!m->mparm[P_WIDTH])
index 1aad595..f16e84f 100644 (file)
@@ -818,6 +818,11 @@ static void parse_config_file(FILE * f)
                }
            } else if (looking_at(p, "start")) {
                start_menu = m;
+           } else if ((ep = looking_at(p, "resolution"))) {
+               int x, y;
+               x = strtoul(ep, &ep, 0);
+               y = strtoul(skipspace(ep), NULL, 0);
+               set_resolution(x, y);
            } else {
                /* Unknown, check for layout parameters */
                enum parameter_number mp;
index df5c94a..22b4623 100644 (file)
@@ -1,6 +1,7 @@
 /* ----------------------------------------------------------------------- *
  *
  *   Copyright 2004-2008 H. Peter Anvin - All Rights Reserved
+ *   Copyright 2009 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
@@ -35,8 +36,12 @@ int draw_background(const char *what)
        return vesacon_load_background(what);
 }
 
-int main(int argc, char *argv[])
+void set_resolution(int x, int y)
+{
+    vesacon_set_resolution(x, y);
+}
+
+void start_console(void)
 {
     openconsole(&dev_rawcon_r, &dev_vesaserial_w);
-    return menu_main(argc, argv);
 }