]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
2007-12-25 Robert Millan <rmh@aybabtu.com>
authorrobertmh <robertmh@localhost>
Tue, 25 Dec 2007 11:10:47 +0000 (11:10 +0000)
committerrobertmh <robertmh@localhost>
Tue, 25 Dec 2007 11:10:47 +0000 (11:10 +0000)
* include/grub/term.h (struct grub_term): Add `getcolor' function.
(grub_getcolor): New function.

* kern/term.c (grub_getcolor): New function.
* normal/menu.c (GRUB_COLOR_MENU_NORMAL): New macro.
(GRUB_COLOR_MENU_HIGHLIGHT): New macro.
(print_entry): Set normal and highlight colors to
`GRUB_COLOR_MENU_NORMAL' and `GRUB_COLOR_MENU_HIGHLIGHT',
respectively, before printing and restore them to old
values afterwards.
(grub_menu_init_page): Likewise.  Fill an additional colored space
that would otherwise be left blank.

* term/efi/console.c (grub_console_getcolor): New function.
(struct grub_console_term.getcolor): New variable.
* term/i386/pc/console.c (grub_console_getcolor): New function.
(struct grub_console_term.getcolor): New variable.
* term/ieee1275/ofconsole.c (grub_ofconsole_getcolor): New function.
(struct grub_console_term.getcolor): New variable.

* term/i386/pc/serial.c (grub_serial_setcolor): Remove function.
(struct grub_console_term.setcolor): Remove variable.
* term/i386/pc/vesafb.c (grub_virtual_screen_setcolor): Remove function.
(struct grub_console_term.setcolor): Remove variable.
* term/i386/pc/vga.c (grub_vga_setcolor): Remove function.
(struct grub_console_term.setcolor): Remove variable.
* term/gfxterm.c (grub_virtual_screen_setcolor): Remove function.
(struct grub_console_term.setcolor): Remove variable.

ChangeLog
include/grub/term.h
kern/term.c
normal/menu.c
term/efi/console.c
term/gfxterm.c
term/i386/pc/console.c
term/i386/pc/serial.c
term/i386/pc/vesafb.c
term/i386/pc/vga.c
term/ieee1275/ofconsole.c

index 7aa2e9f1e275485d67c6d9c21314865a3cd65af5..eff0f90ce97ad438cf8a6f6dcf7bfb37774d8032 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,34 @@
+2007-12-25  Robert Millan  <rmh@aybabtu.com>
+
+       * include/grub/term.h (struct grub_term): Add `getcolor' function.
+       (grub_getcolor): New function.
+
+       * kern/term.c (grub_getcolor): New function.
+       * normal/menu.c (GRUB_COLOR_MENU_NORMAL): New macro.
+       (GRUB_COLOR_MENU_HIGHLIGHT): New macro.
+       (print_entry): Set normal and highlight colors to
+       `GRUB_COLOR_MENU_NORMAL' and `GRUB_COLOR_MENU_HIGHLIGHT',
+       respectively, before printing and restore them to old
+       values afterwards.
+       (grub_menu_init_page): Likewise.  Fill an additional colored space
+       that would otherwise be left blank.
+
+       * term/efi/console.c (grub_console_getcolor): New function.
+       (struct grub_console_term.getcolor): New variable.
+       * term/i386/pc/console.c (grub_console_getcolor): New function.
+       (struct grub_console_term.getcolor): New variable.
+       * term/ieee1275/ofconsole.c (grub_ofconsole_getcolor): New function.
+       (struct grub_console_term.getcolor): New variable.
+
+       * term/i386/pc/serial.c (grub_serial_setcolor): Remove function.
+       (struct grub_console_term.setcolor): Remove variable.
+       * term/i386/pc/vesafb.c (grub_virtual_screen_setcolor): Remove function.
+       (struct grub_console_term.setcolor): Remove variable.
+       * term/i386/pc/vga.c (grub_vga_setcolor): Remove function.
+       (struct grub_console_term.setcolor): Remove variable.
+       * term/gfxterm.c (grub_virtual_screen_setcolor): Remove function.
+       (struct grub_console_term.setcolor): Remove variable.
+
 2007-12-25  Robert Millan  <rmh@aybabtu.com>
 
        * configure.ac: Search for possible unifont.hex locations, and
index 5cdef5377e38e8f59d660eeb4a5410c54269bde2..f9d4e93f51c2826155469f7dbace099641e1b919 100644 (file)
@@ -164,6 +164,10 @@ struct grub_term
      color is VGA's.  */
   void (*setcolor) (grub_uint8_t normal_color, grub_uint8_t highlight_color);
   
+  /* Get the normal color and the highlight color. The format of each
+     color is VGA's.  */
+  void (*getcolor) (grub_uint8_t *normal_color, grub_uint8_t *highlight_color);
+  
   /* Turn on/off the cursor.  */
   void (*setcursor) (int on);
 
@@ -197,6 +201,8 @@ void EXPORT_FUNC(grub_cls) (void);
 void EXPORT_FUNC(grub_setcolorstate) (grub_term_color_state state);
 void EXPORT_FUNC(grub_setcolor) (grub_uint8_t normal_color,
                                 grub_uint8_t highlight_color);
+void EXPORT_FUNC(grub_getcolor) (grub_uint8_t *normal_color,
+                                grub_uint8_t *highlight_color);
 int EXPORT_FUNC(grub_setcursor) (int on);
 int EXPORT_FUNC(grub_getcursor) (void);
 void EXPORT_FUNC(grub_refresh) (void);
index 726adf9e393d27429b1a0d7c7c80375e2a047a64..4c45d713d8b901260089347a6867c2f314da2875 100644 (file)
@@ -230,6 +230,13 @@ grub_setcolor (grub_uint8_t normal_color, grub_uint8_t highlight_color)
     (grub_cur_term->setcolor) (normal_color, highlight_color);
 }
 
+void
+grub_getcolor (grub_uint8_t *normal_color, grub_uint8_t *highlight_color)
+{
+  if (grub_cur_term->getcolor)
+    (grub_cur_term->getcolor) (normal_color, highlight_color);
+}
+
 int
 grub_setcursor (int on)
 {
index 913b730bea3aa247e0714b9cb6b8b3aedfa6bb80..04ee0c1df77bf20e4fa9287ca42389dff41a0d6c 100644 (file)
@@ -25,6 +25,9 @@
 #include <grub/env.h>
 #include <grub/script.h>
 
+#define GRUB_COLOR_MENU_NORMAL         0x07
+#define GRUB_COLOR_MENU_HIGHLIGHT      0x70
+
 static void
 draw_border (void)
 {
@@ -105,7 +108,8 @@ print_entry (int y, int highlight, grub_menu_entry_t entry)
   grub_ssize_t len;
   grub_uint32_t *unicode_title;
   grub_ssize_t i;
-  
+  grub_uint8_t normal_code, highlight_code;
+
   title = entry ? entry->title : "";
   unicode_title = grub_malloc (grub_strlen (title) * sizeof (*unicode_title));
   if (! unicode_title)
@@ -121,6 +125,8 @@ print_entry (int y, int highlight, grub_menu_entry_t entry)
       return;
     }
   
+  grub_getcolor (&normal_code, &highlight_code);
+  grub_setcolor (GRUB_COLOR_MENU_NORMAL, GRUB_COLOR_MENU_HIGHLIGHT);
   grub_setcolorstate (highlight
                      ? GRUB_TERM_COLOR_HIGHLIGHT
                      : GRUB_TERM_COLOR_NORMAL);
@@ -153,8 +159,12 @@ print_entry (int y, int highlight, grub_menu_entry_t entry)
          x++;
        }
     }
+  grub_setcolorstate (GRUB_TERM_COLOR_NORMAL);
+  grub_putchar (' ');
+
   grub_gotoxy (GRUB_TERM_CURSOR_X, y);
 
+  grub_setcolor (normal_code, highlight_code);
   grub_setcolorstate (GRUB_TERM_COLOR_STANDARD);
   grub_free (unicode_title);
 }
@@ -199,9 +209,15 @@ print_entries (grub_menu_t menu, int first, int offset)
 void
 grub_menu_init_page (int nested, int edit)
 {
+  grub_uint8_t normal_code, highlight_code;
+  grub_getcolor (&normal_code, &highlight_code);
+  grub_setcolor (GRUB_COLOR_MENU_NORMAL, GRUB_COLOR_MENU_HIGHLIGHT);
+
   grub_normal_init_page ();
   draw_border ();
   print_message (nested, edit);
+
+  grub_setcolor (normal_code, highlight_code);
 }
 
 /* Return the current timeout. If the variable "timeout" is not set or
index c373bace9bd9fc384a59b916de1fac47aede553e..af198e56e24d6e394c9a8f34ccef1a71cc79aa4a 100644 (file)
@@ -259,6 +259,13 @@ grub_console_setcolor (grub_uint8_t normal_color, grub_uint8_t highlight_color)
   grub_console_highlight_color = highlight_color;
 }
 
+static void
+grub_console_getcolor (grub_uint8_t *normal_color, grub_uint8_t *highlight_color)
+{
+  *normal_color = grub_console_normal_color;
+  *highlight_color = grub_console_highlight_color;
+}
+
 static void
 grub_console_setcursor (int on)
 {
@@ -283,6 +290,7 @@ static struct grub_term grub_console_term =
     .cls = grub_console_cls,
     .setcolorstate = grub_console_setcolorstate,
     .setcolor = grub_console_setcolor,
+    .getcolor = grub_console_getcolor,
     .setcursor = grub_console_setcursor,
     .flags = 0,
     .next = 0
index 7e49a81ad86cfb6287d907d63ef779f22a94ff8c..0ace430a92b7ced41b00ea3edd5b7013a755cc6b 100644 (file)
@@ -839,14 +839,6 @@ grub_virtual_screen_setcolorstate (grub_term_color_state state)
     }
 }
 
-static void
-grub_virtual_screen_setcolor (grub_uint8_t normal_color,
-                              grub_uint8_t highlight_color)
-{
-  virtual_screen.fg_color_setting = grub_video_map_color (normal_color);
-  virtual_screen.bg_color_setting = grub_video_map_color (highlight_color);
-}
-
 static void
 grub_gfxterm_setcursor (int on)
 {
@@ -882,7 +874,6 @@ static struct grub_term grub_video_term =
     .gotoxy = grub_gfxterm_gotoxy,
     .cls = grub_gfxterm_cls,
     .setcolorstate = grub_virtual_screen_setcolorstate,
-    .setcolor = grub_virtual_screen_setcolor,
     .setcursor = grub_gfxterm_setcursor,
     .refresh = grub_gfxterm_refresh,
     .flags = 0,
index 3d5db882dd09be1316c60cb32a7dc52894644a17..9fae1181fb97f3d0a79c8a3fb4afbee5b7e5aabd 100644 (file)
@@ -117,6 +117,13 @@ grub_console_setcolor (grub_uint8_t normal_color, grub_uint8_t highlight_color)
   grub_console_highlight_color = highlight_color;
 }
 
+static void
+grub_console_getcolor (grub_uint8_t *normal_color, grub_uint8_t *highlight_color)
+{
+  *normal_color = grub_console_normal_color;
+  *highlight_color = grub_console_highlight_color;
+}
+
 static struct grub_term grub_console_term =
   {
     .name = "console",
@@ -132,6 +139,7 @@ static struct grub_term grub_console_term =
     .cls = grub_console_cls,
     .setcolorstate = grub_console_setcolorstate,
     .setcolor = grub_console_setcolor,
+    .getcolor = grub_console_getcolor,
     .setcursor = grub_console_setcursor,
     .flags = 0,
     .next = 0
index 578ea404150ac2a0ec1c2c85fef28721f4d56f44..1fc2be1376ff9e640fc5d1dbb2fe0db53332c985 100644 (file)
@@ -453,13 +453,6 @@ grub_serial_setcolorstate (const grub_term_color_state state)
   keep_track = 1;
 }
 
-static void
-grub_serial_setcolor (grub_uint8_t normal_color __attribute__ ((unused)),
-                      grub_uint8_t highlight_color __attribute__ ((unused)))
-{
-  /* FIXME */
-}
-
 static void
 grub_serial_setcursor (const int on)
 {
@@ -483,7 +476,6 @@ static struct grub_term grub_serial_term =
   .gotoxy = grub_serial_gotoxy,
   .cls = grub_serial_cls,
   .setcolorstate = grub_serial_setcolorstate,
-  .setcolor = grub_serial_setcolor,
   .setcursor = grub_serial_setcursor,
   .flags = 0,
   .next = 0
index 8614a3b8a5596fd18e7ac6bb4881910be98a064b..d14ad89cad9814216db4776ba472b5d471aae3eb 100644 (file)
@@ -564,13 +564,6 @@ grub_virtual_screen_setcolorstate (grub_term_color_state state)
     }
 }
 
-static void
-grub_virtual_screen_setcolor (grub_uint8_t normal_color __attribute__ ((unused)),
-                             grub_uint8_t highlight_color __attribute__ ((unused)))
-{
-  /* FIXME */
-}
-
 static void
 grub_vesafb_setcursor (int on)
 {
@@ -599,7 +592,6 @@ static struct grub_term grub_vesafb_term =
     .gotoxy = grub_vesafb_gotoxy,
     .cls = grub_vesafb_cls,
     .setcolorstate = grub_virtual_screen_setcolorstate,
-    .setcolor = grub_virtual_screen_setcolor,
     .setcursor = grub_vesafb_setcursor,
     .flags = 0,
     .next = 0
index 0be79a7f53ed9995b953a781fdd20a54202542cd..16e4dee2479bd6464ee45fad0be8f91dd0bba8d3 100644 (file)
@@ -459,13 +459,6 @@ grub_vga_setcolorstate (grub_term_color_state state)
     }
 }
 
-static void
-grub_vga_setcolor (grub_uint8_t normal_color __attribute__ ((unused)),
-                  grub_uint8_t highlight_color __attribute__ ((unused)))
-{
-  /* FIXME */
-}
-
 static void
 grub_vga_setcursor (int on)
 {
@@ -494,7 +487,6 @@ static struct grub_term grub_vga_term =
     .gotoxy = grub_vga_gotoxy,
     .cls = grub_vga_cls,
     .setcolorstate = grub_vga_setcolorstate,
-    .setcolor = grub_vga_setcolor,
     .setcursor = grub_vga_setcursor,
     .flags = 0,
     .next = 0
index 9eb1202a09b929d3d0eb85d2498ae60c59499d6f..845f198fd42d02f9d789ecaadc50d3cfc1f50c8b 100644 (file)
@@ -129,6 +129,13 @@ grub_ofconsole_setcolor (grub_uint8_t normal_color,
   bgcolor = highlight_color;
 }
 
+static void
+grub_ofconsole_getcolor (grub_uint8_t *normal_color, grub_uint8_t *highlight_color)
+{
+  *normal_color = fgcolor;
+  *highlight_color = bgcolor;
+}
+
 static int
 grub_ofconsole_readkey (int *key)
 {
@@ -364,6 +371,7 @@ static struct grub_term grub_ofconsole_term =
     .cls = grub_ofconsole_cls,
     .setcolorstate = grub_ofconsole_setcolorstate,
     .setcolor = grub_ofconsole_setcolor,
+    .getcolor = grub_ofconsole_getcolor,
     .setcursor = grub_ofconsole_setcursor,
     .refresh = grub_ofconsole_refresh,
     .flags = 0,