]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
Make color variables global instead of it being per-terminal.
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Mon, 21 Jan 2013 16:53:41 +0000 (17:53 +0100)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Mon, 21 Jan 2013 16:53:41 +0000 (17:53 +0100)
17 files changed:
ChangeLog
docs/grub.texi
grub-core/kern/term.c
grub-core/normal/color.c
grub-core/normal/menu_text.c
grub-core/term/arc/console.c
grub-core/term/efi/console.c
grub-core/term/emu/console.c
grub-core/term/gfxterm.c
grub-core/term/i386/pc/console.c
grub-core/term/i386/pc/vga_text.c
grub-core/term/ieee1275/console.c
grub-core/term/morse.c
grub-core/term/serial.c
grub-core/term/spkmodem.c
grub-core/term/terminfo.c
include/grub/term.h

index 35267f5e17a632219dd49f372dad7df37f34d658..32b891a27dec02066c477677c305150112c46e36 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,11 +1,11 @@
 2013-01-21  Vladimir Serbinenko  <phcoder@gmail.com>
 
-       * grub-core/commands/ls.c (grub_ls_print_devices): Add missing
-       asterisk.
+       Make color variables global instead of it being per-terminal.
 
 2013-01-21  Vladimir Serbinenko  <phcoder@gmail.com>
 
-       Make color variables global instead of it being per-terminal.
+       * grub-core/commands/ls.c (grub_ls_print_devices): Add missing
+       asterisk.
 
 2013-01-21  Colin Watson  <cjwatson@ubuntu.com>
 
index b1771116749196adf47ea1c855d21e7c4581bb0f..9941b474283fdbb4eca74302c64216f1063afa44 100644 (file)
@@ -2776,6 +2776,33 @@ those colors.  Each color must be a name from the following list:
 
 The default is @samp{white/black}.
 
+The color support support varies from terminal to terminal.
+
+@samp{morse} has no color support at all.
+
+@samp{mda_text} color support is limited to highlighting by
+black/white reversal.
+
+@samp{console} on ARC and IEEE1275, @samp{serial_*} and
+@samp{spkmodem} are governed by terminfo and support
+only 8 colors if in modes @samp{vt100-color}, @samp{arc}
+(default for console on ARC), @samp{ieee1275} (default
+for console on IEEE1275). When in mode @samp{vt100}
+then the color support is limited to highlighting by black/white
+reversal. When in mode @samp{dumb} there is no color support.
+
+@samp{console} on EMU supports 8 colors.
+
+When console supports no colors this setting is ignored.
+When console supports 8 colors, then the colors from the
+second half of the previous list are mapped to the
+matching colors of first half.
+
+@samp{console} on EFI and BIOS and @samp{vga_text} support all 16 colors.
+
+@samp{gfxterm} supports all 16 colors and would be theoretically extendable
+to support whole rgb24 palette but currently there is no compelling reason
+to go beyond the current 16 colors.
 
 @node debug
 @subsection debug
@@ -4355,6 +4382,8 @@ AT keyboard support allows keyboard layout remapping and support for keys not
 available through firmware. It isn't needed for normal operation except
 baremetal ports.
 
+Speaker allows morse and spkmodem communication.
+
 USB support provides benefits similar to ATA (for USB disks) or AT (for USB
 keyboards). In addition it allows USBserial.
 
@@ -4376,6 +4405,7 @@ and mips-qemu_mips can use only memory up to first hole.
 @item network            @tab yes (*) @tab no       @tab no           @tab no
 @item ATA/AHCI           @tab yes     @tab yes      @tab yes          @tab yes
 @item AT keyboard        @tab yes     @tab yes      @tab yes          @tab yes
+@item Speaker            @tab yes     @tab yes      @tab yes          @tab yes
 @item USB                @tab yes     @tab yes      @tab yes          @tab yes
 @item chainloader        @tab local   @tab yes      @tab yes          @tab no
 @item cpuid              @tab partial @tab partial  @tab partial      @tab partial
@@ -4393,6 +4423,7 @@ and mips-qemu_mips can use only memory up to first hole.
 @item network            @tab yes         @tab yes       @tab yes           @tab yes
 @item ATA/AHCI           @tab yes         @tab yes       @tab yes           @tab no
 @item AT keyboard        @tab yes         @tab yes       @tab yes           @tab no
+@item Speaker            @tab yes         @tab yes       @tab yes           @tab no
 @item USB                @tab yes         @tab yes       @tab yes           @tab no
 @item chainloader        @tab local       @tab local     @tab no            @tab local
 @item cpuid              @tab partial     @tab partial   @tab partial       @tab no
@@ -4410,6 +4441,7 @@ and mips-qemu_mips can use only memory up to first hole.
 @item network            @tab no          @tab yes (*) @tab yes     @tab no
 @item ATA/AHCI           @tab yes         @tab no      @tab no      @tab no
 @item AT keyboard        @tab yes         @tab no      @tab no      @tab no
+@item Speaker            @tab no          @tab no      @tab no      @tab no
 @item USB                @tab yes         @tab no      @tab no      @tab no
 @item chainloader        @tab yes         @tab no      @tab no      @tab no
 @item cpuid              @tab no          @tab no      @tab no      @tab no
@@ -4427,6 +4459,7 @@ and mips-qemu_mips can use only memory up to first hole.
 @item network            @tab no        @tab yes
 @item ATA/AHCI           @tab yes       @tab no
 @item AT keyboard        @tab yes       @tab no
+@item Speaker            @tab no        @tab no
 @item USB                @tab N/A       @tab yes
 @item chainloader        @tab yes       @tab no
 @item cpuid              @tab no        @tab no
index 5014caf624cddf4a914d8f0caecc2027e069e9ed..34096bc5c05b353b2227dff7faa7cb42ccc3d1fd 100644 (file)
@@ -28,6 +28,10 @@ struct grub_term_input *grub_term_inputs_disabled;
 struct grub_term_output *grub_term_outputs;
 struct grub_term_input *grub_term_inputs;
 
+/* Current color state.  */
+grub_uint8_t grub_term_normal_color;
+grub_uint8_t grub_term_highlight_color;
+
 void (*grub_term_poll_usb) (void) = NULL;
 void (*grub_net_poll_cards_idle) (void) = NULL;
 
index 06f1a877c2bca6c574797fac1fb16401af503fc4..c2654239f4b384fc9c368ffa8058f9b21753240f 100644 (file)
@@ -106,8 +106,6 @@ free_and_return:
   return result;
 }
 
-static grub_uint8_t color_normal, color_highlight;
-
 static void
 set_colors (void)
 {
@@ -115,9 +113,6 @@ set_colors (void)
 
   FOR_ACTIVE_TERM_OUTPUTS(term)
   {
-    /* Reloads terminal `normal' and `highlight' colors.  */
-    grub_term_setcolor (term, color_normal, color_highlight);
-
     /* Propagates `normal' color to terminal current color.  */
     grub_term_setcolorstate (term, GRUB_TERM_COLOR_NORMAL);
   }
@@ -128,7 +123,7 @@ char *
 grub_env_write_color_normal (struct grub_env_var *var __attribute__ ((unused)),
                             const char *val)
 {
-  if (grub_parse_color_name_pair (&color_normal, val))
+  if (grub_parse_color_name_pair (&grub_term_normal_color, val))
     return NULL;
 
   set_colors ();
@@ -141,7 +136,7 @@ char *
 grub_env_write_color_highlight (struct grub_env_var *var __attribute__ ((unused)),
                                const char *val)
 {
-  if (grub_parse_color_name_pair (&color_highlight, val))
+  if (grub_parse_color_name_pair (&grub_term_highlight_color, val))
     return NULL;
 
   set_colors ();
index 1687c2841e81389221d90f31b709385e26f230cb..80a7cd9571b92221f53fb6a4186f0b47d73f0c4a 100644 (file)
@@ -225,8 +225,10 @@ print_entry (int y, int highlight, grub_menu_entry_t entry,
       return;
     }
 
-  grub_term_getcolor (term, &old_color_normal, &old_color_highlight);
-  grub_term_setcolor (term, grub_color_menu_normal, grub_color_menu_highlight);
+  old_color_normal = grub_term_normal_color;
+  old_color_highlight = grub_term_highlight_color;
+  grub_term_normal_color = grub_color_menu_normal;
+  grub_term_highlight_color = grub_color_menu_highlight;
   grub_term_setcolorstate (term, highlight
                           ? GRUB_TERM_COLOR_HIGHLIGHT
                           : GRUB_TERM_COLOR_NORMAL);
@@ -293,7 +295,9 @@ print_entry (int y, int highlight, grub_menu_entry_t entry,
 
   grub_term_gotoxy (term, grub_term_cursor_x (term), y);
 
-  grub_term_setcolor (term, old_color_normal, old_color_highlight);
+  grub_term_normal_color = old_color_normal;
+  grub_term_highlight_color = old_color_highlight;
+
   grub_term_setcolorstate (term, GRUB_TERM_COLOR_NORMAL);
   grub_free (unicode_title);
 }
@@ -349,11 +353,11 @@ grub_menu_init_page (int nested, int edit, int *num_entries,
   *num_entries = grub_term_height (term) - GRUB_TERM_TOP_BORDER_Y
     - (print_message (nested, edit, term, 1) + 3) - 2;
 
-  grub_term_getcolor (term, &old_color_normal, &old_color_highlight);
-
   /* By default, use the same colors for the menu.  */
-  grub_color_menu_normal = old_color_normal;
-  grub_color_menu_highlight = old_color_highlight;
+  old_color_normal = grub_term_normal_color;
+  old_color_highlight = grub_term_highlight_color;
+  grub_color_menu_normal = grub_term_normal_color;
+  grub_color_menu_highlight = grub_color_menu_highlight;
 
   /* Then give user a chance to replace them.  */
   grub_parse_color_name_pair (&grub_color_menu_normal,
@@ -362,9 +366,11 @@ grub_menu_init_page (int nested, int edit, int *num_entries,
                              grub_env_get ("menu_color_highlight"));
 
   grub_normal_init_page (term);
-  grub_term_setcolor (term, grub_color_menu_normal, grub_color_menu_highlight);
+  grub_term_normal_color = grub_color_menu_normal;
+  grub_term_highlight_color = grub_color_menu_highlight;
   draw_border (term, *num_entries);
-  grub_term_setcolor (term, old_color_normal, old_color_highlight);
+  grub_term_normal_color = old_color_normal;
+  grub_term_highlight_color = old_color_highlight;
   print_message (nested, edit, term, 0);
 }
 
index 45ff26760a2e8b7b1b0bf7a16c7738b2d4c08999..0ccaebe0a96f51f76848a9012ee742fe2230701c 100644 (file)
@@ -102,8 +102,6 @@ static struct grub_term_output grub_console_term_output =
     .setcursor = grub_terminfo_setcursor,
     .flags = GRUB_TERM_CODE_TYPE_ASCII,
     .data = &grub_console_terminfo_output,
-    .normal_color = GRUB_TERM_DEFAULT_NORMAL_COLOR,
-    .highlight_color = GRUB_TERM_DEFAULT_HIGHLIGHT_COLOR,
   };
 
 void
index e57a815b01039dd8b9f390796fc90d201a8d87e0..2d6c6f9b94ea059b2070870c49648f9b35579753 100644 (file)
@@ -192,7 +192,8 @@ grub_console_cls (struct grub_term_output *term __attribute__ ((unused)))
 }
 
 static void
-grub_console_setcolorstate (struct grub_term_output *term,
+grub_console_setcolorstate (struct grub_term_output *term
+                           __attribute__ ((unused)),
                            grub_term_color_state state)
 {
   grub_efi_simple_text_output_interface_t *o;
@@ -208,10 +209,10 @@ grub_console_setcolorstate (struct grub_term_output *term,
                  & 0x7f);
       break;
     case GRUB_TERM_COLOR_NORMAL:
-      efi_call_2 (o->set_attributes, o, term->normal_color & 0x7f);
+      efi_call_2 (o->set_attributes, o, grub_term_normal_color & 0x7f);
       break;
     case GRUB_TERM_COLOR_HIGHLIGHT:
-      efi_call_2 (o->set_attributes, o, term->highlight_color & 0x7f);
+      efi_call_2 (o->set_attributes, o, grub_term_highlight_color & 0x7f);
       break;
     default:
       break;
@@ -265,8 +266,6 @@ static struct grub_term_output grub_console_term_output =
     .cls = grub_console_cls,
     .setcolorstate = grub_console_setcolorstate,
     .setcursor = grub_console_setcursor,
-    .normal_color = GRUB_TERM_DEFAULT_NORMAL_COLOR,
-    .highlight_color = GRUB_TERM_DEFAULT_HIGHLIGHT_COLOR,
     .flags = GRUB_TERM_CODE_TYPE_VISUAL_GLYPHS
   };
 
index 55e3a6b7f2ac0abee551136a56923ca4575f3f62..5bd5db1d86abe3c65645589d5c225eeab64ee747 100644 (file)
@@ -82,11 +82,11 @@ grub_ncurses_setcolorstate (struct grub_term_output *term,
       grub_console_attr = A_NORMAL;
       break;
     case GRUB_TERM_COLOR_NORMAL:
-      grub_console_cur_color = term->normal_color;
+      grub_console_cur_color = grub_term_normal_color;
       grub_console_attr = A_NORMAL;
       break;
     case GRUB_TERM_COLOR_HIGHLIGHT:
-      grub_console_cur_color = term->highlight_color;
+      grub_console_cur_color = grub_term_highlight_color;
       grub_console_attr = A_STANDOUT;
       break;
     default:
index 12567d100de88a1e7faa9fdbd7ff1b397512b0c2..a168e01cfe7e404965415a9f0e470b8846004236 100644 (file)
@@ -1036,7 +1036,7 @@ grub_gfxterm_cls (struct grub_term_output *term)
 }
 
 static void
-grub_virtual_screen_setcolorstate (struct grub_term_output *term,
+grub_virtual_screen_setcolorstate (struct grub_term_output *term __attribute__ ((unused)),
                                   grub_term_color_state state)
 {
   switch (state)
@@ -1046,11 +1046,11 @@ grub_virtual_screen_setcolorstate (struct grub_term_output *term,
       break;
 
     case GRUB_TERM_COLOR_NORMAL:
-      virtual_screen.term_color = term->normal_color;
+      virtual_screen.term_color = grub_term_normal_color;
       break;
 
     case GRUB_TERM_COLOR_HIGHLIGHT:
-      virtual_screen.term_color = term->highlight_color;
+      virtual_screen.term_color = grub_term_highlight_color;
       break;
 
     default:
@@ -1246,8 +1246,6 @@ static struct grub_term_output grub_video_term =
     .refresh = grub_gfxterm_refresh,
     .fullscreen = grub_gfxterm_fullscreen,
     .flags = GRUB_TERM_CODE_TYPE_VISUAL_GLYPHS,
-    .normal_color = GRUB_TERM_DEFAULT_NORMAL_COLOR,
-    .highlight_color = GRUB_TERM_DEFAULT_HIGHLIGHT_COLOR,
     .next = 0
   };
 
index a6814352508fe898fee56e8211eb46864d21b03a..2aa1943a583b38c51070ec7230d3e2bfe1442725 100644 (file)
@@ -259,7 +259,8 @@ grub_console_getwh (struct grub_term_output *term __attribute__ ((unused)))
 }
 
 static void
-grub_console_setcolorstate (struct grub_term_output *term,
+grub_console_setcolorstate (struct grub_term_output *term
+                           __attribute__ ((unused)),
                            grub_term_color_state state)
 {
   switch (state) {
@@ -267,10 +268,10 @@ grub_console_setcolorstate (struct grub_term_output *term,
       grub_console_cur_color = GRUB_TERM_DEFAULT_STANDARD_COLOR & 0x7f;
       break;
     case GRUB_TERM_COLOR_NORMAL:
-      grub_console_cur_color = term->normal_color & 0x7f;
+      grub_console_cur_color = grub_term_normal_color & 0x7f;
       break;
     case GRUB_TERM_COLOR_HIGHLIGHT:
-      grub_console_cur_color = term->highlight_color & 0x7f;
+      grub_console_cur_color = grub_term_highlight_color & 0x7f;
       break;
     default:
       break;
@@ -295,8 +296,6 @@ static struct grub_term_output grub_console_term_output =
     .setcolorstate = grub_console_setcolorstate,
     .setcursor = grub_console_setcursor,
     .flags = GRUB_TERM_CODE_TYPE_CP437,
-    .normal_color = GRUB_TERM_DEFAULT_NORMAL_COLOR,
-    .highlight_color = GRUB_TERM_DEFAULT_HIGHLIGHT_COLOR,
   };
 
 void
index 74c155c530e57708b3a106e0b99beffe11707c57..e976aec9b8cde23043c30501f95dbb81d857ce9c 100644 (file)
@@ -209,18 +209,18 @@ grub_vga_text_getwh (struct grub_term_output *term __attribute__ ((unused)))
 #ifndef MODE_MDA
 
 static void
-grub_vga_text_setcolorstate (struct grub_term_output *term,
-                           grub_term_color_state state)
+grub_vga_text_setcolorstate (struct grub_term_output *term __attribute__ ((unused)),
+                            grub_term_color_state state)
 {
   switch (state) {
     case GRUB_TERM_COLOR_STANDARD:
       cur_color = GRUB_TERM_DEFAULT_STANDARD_COLOR & 0x7f;
       break;
     case GRUB_TERM_COLOR_NORMAL:
-      cur_color = term->normal_color & 0x7f;
+      cur_color = grub_term_normal_color & 0x7f;
       break;
     case GRUB_TERM_COLOR_HIGHLIGHT:
-      cur_color = term->highlight_color & 0x7f;
+      cur_color = grub_term_highlight_color & 0x7f;
       break;
     default:
       break;
@@ -265,8 +265,6 @@ static struct grub_term_output grub_vga_text_term =
     .setcolorstate = grub_vga_text_setcolorstate,
     .setcursor = grub_vga_text_setcursor,
     .flags = GRUB_TERM_CODE_TYPE_CP437,
-    .normal_color = GRUB_TERM_DEFAULT_NORMAL_COLOR,
-    .highlight_color = GRUB_TERM_DEFAULT_HIGHLIGHT_COLOR,
   };
 
 #ifdef MODE_MDA
index 93b81f441407a248e84afd28a34b74b4f2bdf59b..3a808640e5771df7a199478b2c793768d3294b61 100644 (file)
@@ -229,8 +229,6 @@ static struct grub_term_output grub_console_term_output =
     .setcursor = grub_console_setcursor,
     .flags = GRUB_TERM_CODE_TYPE_ASCII,
     .data = &grub_console_terminfo_output,
-    .normal_color = GRUB_TERM_DEFAULT_NORMAL_COLOR,
-    .highlight_color = GRUB_TERM_DEFAULT_HIGHLIGHT_COLOR,
   };
 
 void
index 3d6c650887f4221aa61ddaacca6197ca4f76699b..0fdc3b416893250d3c96d4c49a9c7b89a86a9696 100644 (file)
@@ -115,8 +115,6 @@ static struct grub_term_output grub_audio_term_output =
    .cls = (void *) dummy,
    .setcolorstate = (void *) dummy,
    .setcursor = (void *) dummy,
-   .normal_color = GRUB_TERM_DEFAULT_NORMAL_COLOR,
-   .highlight_color = GRUB_TERM_DEFAULT_HIGHLIGHT_COLOR,
    .flags = GRUB_TERM_CODE_TYPE_ASCII | GRUB_TERM_DUMB
   };
 
index e1469e57ae813b14e96f1405dd8045e1dde6c9e3..cfcfe8484db26580a41091c7e57c60f90df31c11 100644 (file)
@@ -121,8 +121,6 @@ static struct grub_term_output grub_serial_term_output =
   .setcursor = grub_terminfo_setcursor,
   .flags = GRUB_TERM_CODE_TYPE_ASCII,
   .data = &grub_serial_terminfo_output,
-  .normal_color = GRUB_TERM_DEFAULT_NORMAL_COLOR,
-  .highlight_color = GRUB_TERM_DEFAULT_HIGHLIGHT_COLOR,
 };
 
 \f
index b6e7a049e9f1b03efee2ff919068279db4c7aa34..5bff429e3f81e82c604ac072b3231aa12f9fefdf 100644 (file)
@@ -127,8 +127,6 @@ static struct grub_term_output grub_spkmodem_term_output =
     .setcursor = grub_terminfo_setcursor,
     .flags = GRUB_TERM_CODE_TYPE_ASCII,
     .data = &grub_spkmodem_terminfo_output,
-    .normal_color = GRUB_TERM_DEFAULT_NORMAL_COLOR,
-    .highlight_color = GRUB_TERM_DEFAULT_HIGHLIGHT_COLOR,
   };
 
 GRUB_MOD_INIT (spkmodem)
index a0f8d18af0c2f877498eb0172b120cbf48ad317d..eb0ef00eabe44422674d73a9738c6acf0401a74e 100644 (file)
@@ -303,12 +303,12 @@ grub_terminfo_setcolorstate (struct grub_term_output *term,
        {
        case GRUB_TERM_COLOR_STANDARD:
        case GRUB_TERM_COLOR_NORMAL:
-         fg = term->normal_color & 0x0f;
-         bg = term->normal_color >> 4;
+         fg = grub_term_normal_color & 0x0f;
+         bg = grub_term_normal_color >> 4;
          break;
        case GRUB_TERM_COLOR_HIGHLIGHT:
-         fg = term->highlight_color & 0x0f;
-         bg = term->highlight_color >> 4;
+         fg = grub_term_highlight_color & 0x0f;
+         bg = grub_term_highlight_color >> 4;
          break;
        default:
          return;
index 39c3d5a6c27127b304a820bc4f5e4ccb7aff9580..84f576685cdda05679b2c7622d18067fbb34763b 100644 (file)
@@ -221,10 +221,6 @@ struct grub_term_output
   /* The feature flags defined above.  */
   grub_uint32_t flags;
 
-  /* Current color state.  */
-  grub_uint8_t normal_color;
-  grub_uint8_t highlight_color;
-
   void *data;
 };
 typedef struct grub_term_output *grub_term_output_t;
@@ -233,6 +229,10 @@ typedef struct grub_term_output *grub_term_output_t;
 #define GRUB_TERM_DEFAULT_HIGHLIGHT_COLOR 0x70
 #define GRUB_TERM_DEFAULT_STANDARD_COLOR 0x07
 
+/* Current color state.  */
+extern grub_uint8_t EXPORT_VAR(grub_term_normal_color);
+extern grub_uint8_t EXPORT_VAR(grub_term_highlight_color);
+
 extern struct grub_term_output *EXPORT_VAR(grub_term_outputs_disabled);
 extern struct grub_term_input *EXPORT_VAR(grub_term_inputs_disabled);
 extern struct grub_term_output *EXPORT_VAR(grub_term_outputs);
@@ -391,16 +391,6 @@ grub_setcolorstate (grub_term_color_state state)
     grub_term_setcolorstate (term, state);
 }
 
-/* Set the normal color and the highlight color. The format of each
-   color is VGA's.  */
-static inline void 
-grub_term_setcolor (struct grub_term_output *term,
-                   grub_uint8_t normal_color, grub_uint8_t highlight_color)
-{
-  term->normal_color = normal_color;
-  term->highlight_color = highlight_color;
-}
-
 /* Turn on/off the cursor.  */
 static inline void 
 grub_term_setcursor (struct grub_term_output *term, int on)
@@ -460,14 +450,6 @@ grub_term_getcharwidth (struct grub_term_output *term,
     return 1;
 }
 
-static inline void 
-grub_term_getcolor (struct grub_term_output *term, 
-                   grub_uint8_t *normal_color, grub_uint8_t *highlight_color)
-{
-  *normal_color = term->normal_color;
-  *highlight_color = term->highlight_color;
-}
-
 struct grub_term_autoload
 {
   struct grub_term_autoload *next;