bug-grub
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-grub] color problem in CVS grub


From: Jason Thomas
Subject: Re: [Bug-grub] color problem in CVS grub
Date: Thu, 22 Aug 2002 10:32:17 +1000
User-agent: Mutt/1.4i

okay I found that little bug, try this patch!

On Wed, Aug 21, 2002 at 07:54:22PM -0400, Pavel Roskin wrote:
> Hi, Jason!
> 
> > any feedback on this! I'd like to get this in and package up a CVS
> > snapshot for debian unstable, so we can get some more testing!
> 
> Works for me just fine at boot.  The grub shell still has some ugly 
> highlighting.


Index: ChangeLog
===================================================================
RCS file: /cvsroot/grub/grub/ChangeLog,v
retrieving revision 1.517
diff -u -r1.517 ChangeLog
--- ChangeLog   12 Jul 2002 09:55:54 -0000      1.517
+++ ChangeLog   22 Aug 2002 00:31:11 -0000
@@ -1,3 +1,37 @@
+2002-09-20  Jason Thomas <address@hidden>
+
+   * stage2/term.h:
+   changed highlight state code for hercules, console and serial
+   state was 0 - normal or 1 - highlight.
+   state is now defined using an typedef enum color_state,
+   which has:
+   (COLOR_STATE_STANDARD): standard color to use when not using user defined
+   (COLOR_STATE_NORMAL): user defined normal color
+   (COLOR_STATE_HIGHLIGHT): user defined highlight color
+   * stage2/hercules.c:
+   (herc_highlight_state): removed
+   (herc_standard_color): New variable
+   (herc_color_state): New variable
+   (herc_highlight): renamed to herc_setcolorstate
+   (herc_setcolorstate): added switch to handle new states
+   * stage2/console.c:
+   (console_highlight_state): removed
+   (console_standard_color): New variable
+   (console_color_state): New variable
+   (console_highlight): renamed to console_setcolorstate
+   (console_setcolorstate): added switch to handle new states
+   * stage2/serial.c:
+   (serial_highlight): renamed to serial_setcolorstate
+   (serial_setcolorstate): adjusted 'if' to suit new states
+   * grub/asmstub.c:
+   (console_highlight): renamed to console_setcolorstate
+   (console_setcolorstate): adjusted 'if' to suit new states
+   * stage2/stage2.c:
+   (print_entry, print_border): set color states using new states.
+   * stage2/stage2.c:
+   (run_menu): reverse if (!) to if () for uniformitty.
+   * stage2/term.h: updated prototypes to reflect above function changes.
+
 2002-07-12  Yoshinori K. Okuji  <address@hidden>
 
        * stage2/boot.c (load_image): Rewrite the Linux booting support
Index: grub/asmstub.c
===================================================================
RCS file: /cvsroot/grub/grub/grub/asmstub.c,v
retrieving revision 1.75
diff -u -r1.75 asmstub.c
--- grub/asmstub.c      12 Jul 2002 09:55:55 -0000      1.75
+++ grub/asmstub.c      22 Aug 2002 00:31:13 -0000
@@ -727,9 +727,10 @@
 }
 
 void
-console_highlight (int state)
+console_setcolorstate (color_state state)
 {
-  console_current_color = state ? A_REVERSE : A_NORMAL;
+  console_current_color = 
+    (state == COLOR_STATE_HIGHLIGHT) ? A_REVERSE : A_NORMAL;
 }
 
 void
@@ -1250,9 +1251,9 @@
 }
 
 void
-hercules_highlight (int state)
+hercules_setcolorstate (color_state state)
 {
-  console_highlight (state);
+  console_setcolorstate (state);
 }
 
 void
Index: stage2/char_io.c
===================================================================
RCS file: /cvsroot/grub/grub/stage2/char_io.c,v
retrieving revision 1.47
diff -u -r1.47 char_io.c
--- stage2/char_io.c    11 Jun 2002 16:36:54 -0000      1.47
+++ stage2/char_io.c    22 Aug 2002 00:31:14 -0000
@@ -41,7 +41,7 @@
       console_getxy,
       console_gotoxy,
       console_cls,
-      console_highlight,
+      console_setcolorstate,
       console_setcolor,
       console_nocursor
     },
@@ -56,7 +56,7 @@
       serial_getxy,
       serial_gotoxy,
       serial_cls,
-      serial_highlight,
+      serial_setcolorstate,
       0,
       0
     },
@@ -71,7 +71,7 @@
       hercules_getxy,
       hercules_gotoxy,
       hercules_cls,
-      hercules_highlight,
+      hercules_setcolorstate,
       hercules_setcolor,
       hercules_nocursor
     },      
@@ -1028,13 +1028,13 @@
                 the following grub_printf call will print newlines.  */
              count_lines = -1;
 
-             if (current_term->highlight)
-               current_term->highlight (1);
+             if (current_term->setcolorstate)
+               current_term->setcolorstate (COLOR_STATE_HIGHLIGHT);
              
              grub_printf ("\n[Hit return to continue]");
 
-             if (current_term->highlight)
-               current_term->highlight (0);
+             if (current_term->setcolorstate)
+               current_term->setcolorstate (COLOR_STATE_NORMAL);
              
              do
                {
Index: stage2/console.c
===================================================================
RCS file: /cvsroot/grub/grub/stage2/console.c,v
retrieving revision 1.1
diff -u -r1.1 console.c
--- stage2/console.c    11 Jun 2002 20:08:17 -0000      1.1
+++ stage2/console.c    22 Aug 2002 00:31:14 -0000
@@ -26,16 +26,30 @@
    console_gotoxy, console_cls, and console_nocursor.  */
 
 int console_current_color = A_NORMAL;
+static int console_standard_color = A_NORMAL;
 static int console_normal_color = A_NORMAL;
 static int console_highlight_color = A_REVERSE;
-static int console_highlight_state = 0;
+static color_state console_color_state = COLOR_STATE_STANDARD;
 
 void
-console_highlight (int state)
+console_setcolorstate (color_state state)
 {
-  console_current_color
-    = state ? console_highlight_color : console_normal_color;
-  console_highlight_state = state;
+  switch (state) {
+    case COLOR_STATE_STANDARD:
+      console_current_color = console_standard_color;
+      break;
+    case COLOR_STATE_NORMAL:
+      console_current_color = console_normal_color;
+      break;
+    case COLOR_STATE_HIGHLIGHT:
+      console_current_color = console_highlight_color;
+      break;
+    default:
+      console_current_color = console_standard_color;
+      break;
+  }
+
+  console_color_state = state;
 }
 
 void
@@ -44,5 +58,5 @@
   console_normal_color = normal_color;
   console_highlight_color = highlight_color;
 
-  console_highlight (console_highlight_state);
+  console_setcolorstate (console_color_state);
 }
Index: stage2/hercules.c
===================================================================
RCS file: /cvsroot/grub/grub/stage2/hercules.c,v
retrieving revision 1.2
diff -u -r1.2 hercules.c
--- stage2/hercules.c   11 Jun 2002 16:36:54 -0000      1.2
+++ stage2/hercules.c   22 Aug 2002 00:31:15 -0000
@@ -28,10 +28,11 @@
 static int herc_x;
 static int herc_y;
 
+static int herc_standard_color = A_NORMAL;
 static int herc_normal_color = A_NORMAL;
 static int herc_highlight_color = A_REVERSE;
 static int herc_current_color = A_NORMAL;
-static int herc_highlight_state = 0;
+static color_state herc_color_state = COLOR_STATE_STANDARD;
 
 /* Write a byte to a port.  */
 static inline void
@@ -148,10 +149,24 @@
 }
 
 void
-hercules_highlight (int state)
+hercules_setcolorstate (color_state state)
 {
-  herc_current_color = state ? herc_highlight_color : herc_normal_color;
-  herc_highlight_state = state;
+  switch (state) {
+    case COLOR_STATE_STANDARD:
+      herc_current_color = herc_standard_color;
+      break;
+    case COLOR_STATE_NORMAL:
+      herc_current_color = herc_normal_color;
+      break;
+    case COLOR_STATE_HIGHLIGHT:
+      herc_current_color = herc_highlight_color;
+      break;
+    default:
+      herc_current_color = herc_standard_color;
+      break;
+  }
+
+  herc_color_state = state;
 }
 
 void
@@ -160,7 +175,7 @@
   herc_normal_color = normal_color;
   herc_highlight_color = highlight_color;
   
-  hercules_highlight (herc_highlight_state);
+  hercules_setcolorstate (herc_color_state);
 }
 
 void
Index: stage2/serial.c
===================================================================
RCS file: /cvsroot/grub/grub/stage2/serial.c,v
retrieving revision 1.9
diff -u -r1.9 serial.c
--- stage2/serial.c     2 Jul 2002 23:39:14 -0000       1.9
+++ stage2/serial.c     22 Aug 2002 00:31:15 -0000
@@ -414,10 +414,10 @@
 }
 
 void
-serial_highlight (int state)
+serial_setcolorstate (color_state state)
 {
   keep_track = 0;
-  grub_printf ("\e[%cm", state ? '7' : '0');
+  grub_printf ("\e[%cm", (state == COLOR_STATE_HIGHLIGHT) ? '7' : '0');
   keep_track = 1;
 }
 
Index: stage2/stage2.c
===================================================================
RCS file: /cvsroot/grub/grub/stage2/stage2.c,v
retrieving revision 1.37
diff -u -r1.37 stage2.c
--- stage2/stage2.c     11 Jun 2002 16:36:54 -0000      1.37
+++ stage2/stage2.c     22 Aug 2002 00:31:16 -0000
@@ -98,11 +98,12 @@
 print_entry (int y, int highlight, char *entry)
 {
   int x;
+
+  if (current_term->setcolorstate)
+    current_term->setcolorstate (COLOR_STATE_NORMAL);
   
-  highlight = (highlight && current_term->highlight);
-  
-  if (highlight)
-    current_term->highlight (1);
+  if (highlight && current_term->setcolorstate)
+    current_term->setcolorstate (COLOR_STATE_HIGHLIGHT);
 
   gotoxy (2, y);
   grub_putchar (' ');
@@ -115,8 +116,8 @@
     }
   gotoxy (74, y);
 
-  if (highlight)
-    current_term->highlight (0);
+  if (current_term->setcolorstate)
+    current_term->setcolorstate (COLOR_STATE_STANDARD);
 }
 
 /* Print entries in the menu box.  */
@@ -186,6 +187,9 @@
 print_border (int y, int size)
 {
   int i;
+
+  if (current_term->setcolorstate)
+    current_term->setcolorstate (COLOR_STATE_NORMAL);
   
   gotoxy (1, y);
 
@@ -213,6 +217,9 @@
   for (i = 0; i < 73; i++)
     grub_putchar (DISP_HORIZ);
   grub_putchar (DISP_LR);
+
+  if (current_term->setcolorstate)
+    current_term->setcolorstate (COLOR_STATE_STANDARD);
 }
 
 static void
@@ -287,10 +294,10 @@
       init_page ();
       nocursor ();
 
-      if (! (current_term->flags & TERM_DUMB))
-       print_border (3, 12);
-      else
+      if (current_term->flags & TERM_DUMB)
        print_entries_raw (num_entries, first_entry, menu_entries);
+      else
+       print_border (3, 12);
 
       grub_printf ("\n\
       Use the %c and %c keys to select which entry is highlighted.\n",
Index: stage2/term.h
===================================================================
RCS file: /cvsroot/grub/grub/stage2/term.h,v
retrieving revision 1.1
diff -u -r1.1 term.h
--- stage2/term.h       11 Jun 2002 20:08:17 -0000      1.1
+++ stage2/term.h       22 Aug 2002 00:31:16 -0000
@@ -21,6 +21,19 @@
 #ifndef GRUB_TERM_HEADER
 #define GRUB_TERM_HEADER       1
 
+/* These are used to represent the various color states we use */
+typedef enum
+{
+  /* represents the color used to display all text that does not use the user
+   * defined colors below
+   */
+  COLOR_STATE_STANDARD,
+  /* represents the user defined colors for normal text */
+  COLOR_STATE_NORMAL,
+  /* represents the user defined colors for highlighted text */
+  COLOR_STATE_HIGHLIGHT
+} color_state;
+
 #ifndef STAGE1_5
 
 /* Flags for representing the capabilities of a terminal.  */
@@ -59,8 +72,8 @@
   void (*gotoxy) (int x, int y);
   /* Clear the screen.  */
   void (*cls) (void);
-  /* Highlight characters written after this call, if STATE is true.  */
-  void (*highlight) (int state);
+  /* Set the current color to be used */
+  void (*setcolorstate) (color_state state);
   /* Set the normal color and the highlight color. The format of each
      color is VGA's.  */
   void (*setcolor) (int normal_color, int highlight_color);
@@ -86,7 +99,7 @@
 int console_getxy (void);
 void console_gotoxy (int x, int y);
 void console_cls (void);
-void console_highlight (int state);
+void console_setcolorstate (color_state state);
 void console_setcolor (int normal_color, int highlight_color);
 void console_nocursor (void);
 #endif
@@ -98,7 +111,7 @@
 int serial_getxy (void);
 void serial_gotoxy (int x, int y);
 void serial_cls (void);
-void serial_highlight (int state);
+void serial_setcolorstate (color_state state);
 #endif
 
 #ifdef SUPPORT_HERCULES
@@ -106,7 +119,7 @@
 int hercules_getxy (void);
 void hercules_gotoxy (int x, int y);
 void hercules_cls (void);
-void hercules_highlight (int state);
+void hercules_setcolorstate (color_state state);
 void hercules_setcolor (int normal_color, int highlight_color);
 void hercules_nocursor (void);
 #endif




reply via email to

[Prev in Thread] Current Thread [Next in Thread]