All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] do not ignore current values for {normal,highlight}_color when loading terminal output  module
@ 2012-10-04 17:06 Andrey Borzenkov
  0 siblings, 0 replies; only message in thread
From: Andrey Borzenkov @ 2012-10-04 17:06 UTC (permalink / raw)
  To: grub-devel

[-- Attachment #1: Type: text/plain, Size: 765 bytes --]

Currently every loaded module starts with hardcoded default colors,
ignoring current value of variables normal_color and highlight_color.
This provides inconsistent experience because which color is actually
used for terminal window depends in which place of grub.cfg color is
set. Additionally even if color is set in terminal window, terminal is
closed and reopened again, color is reset to hardcoded default.

The patch makes sure current values are applied on module load. Also
normal_color is applied when new instance of terminal window is created.

In principle this patch makes term->normal_color and
term->highlight_color redundant, as there is no place where they are set
individually, they always follow variables normal_color,
highlight_color.

-andrey

[-- Attachment #2: grub2-dont-ignore-default-colors.patch --]
[-- Type: text/x-patch, Size: 4663 bytes --]

=== modified file 'grub-core/kern/term.c'
Index: b/grub-core/kern/term.c
===================================================================
--- a/grub-core/kern/term.c
+++ b/grub-core/kern/term.c
@@ -23,6 +23,9 @@
 #include <grub/env.h>
 #include <grub/time.h>
 
+grub_uint8_t grub_term_normal_color = GRUB_TERM_DEFAULT_NORMAL_COLOR;
+grub_uint8_t grub_term_highlight_color = GRUB_TERM_DEFAULT_HIGHLIGHT_COLOR;
+
 struct grub_term_output *grub_term_outputs_disabled;
 struct grub_term_input *grub_term_inputs_disabled;
 struct grub_term_output *grub_term_outputs;
Index: b/grub-core/normal/color.c
===================================================================
--- a/grub-core/normal/color.c
+++ b/grub-core/normal/color.c
@@ -106,8 +106,6 @@ free_and_return:
   return result;
 }
 
-static grub_uint8_t color_normal, color_highlight;
-
 static void
 set_colors (void)
 {
@@ -116,7 +114,7 @@ set_colors (void)
   FOR_ACTIVE_TERM_OUTPUTS(term)
   {
     /* Reloads terminal `normal' and `highlight' colors.  */
-    grub_term_setcolor (term, color_normal, color_highlight);
+    grub_term_setcolor (term, grub_term_normal_color, grub_term_highlight_color);
 
     /* Propagates `normal' color to terminal current color.  */
     grub_term_setcolorstate (term, GRUB_TERM_COLOR_NORMAL);
@@ -128,7 +126,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 +139,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: b/grub-core/normal/main.c
===================================================================
--- a/grub-core/normal/main.c
+++ b/grub-core/normal/main.c
@@ -539,8 +539,8 @@ GRUB_MOD_INIT(normal)
   grub_env_export ("color_highlight");
 
   /* Set default color names.  */
-  grub_env_set ("color_normal", "white/black");
-  grub_env_set ("color_highlight", "black/white");
+  grub_env_set ("color_normal", "light-gray/black");
+  grub_env_set ("color_highlight", "black/light-gray");
 
   for (i = 0; i < ARRAY_SIZE (features); i++)
     {
Index: b/grub-core/term/gfxterm.c
===================================================================
--- a/grub-core/term/gfxterm.c
+++ b/grub-core/term/gfxterm.c
@@ -253,7 +253,7 @@ grub_virtual_screen_setup (unsigned int
 
   virtual_screen.standard_color_setting = DEFAULT_STANDARD_COLOR;
 
-  virtual_screen.term_color = GRUB_TERM_DEFAULT_NORMAL_COLOR;
+  virtual_screen.term_color = grub_term_normal_color;
 
   set_term_color (virtual_screen.term_color);
 
Index: b/include/grub/term.h
===================================================================
--- a/include/grub/term.h
+++ b/include/grub/term.h
@@ -233,6 +233,9 @@ typedef struct grub_term_output *grub_te
 #define GRUB_TERM_DEFAULT_HIGHLIGHT_COLOR 0x70
 #define GRUB_TERM_DEFAULT_STANDARD_COLOR 0x07
 
+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);
@@ -273,6 +276,9 @@ static inline void
 grub_term_register_output (const char *name __attribute__ ((unused)),
 			   grub_term_output_t term)
 {
+  term->normal_color = grub_term_normal_color;
+  term->highlight_color = grub_term_highlight_color;
+
   if (grub_term_outputs)
     grub_list_push (GRUB_AS_LIST_P (&grub_term_outputs_disabled),
 		    GRUB_AS_LIST (term));
@@ -289,6 +295,9 @@ static inline void
 grub_term_register_output_inactive (const char *name __attribute__ ((unused)),
 				    grub_term_output_t term)
 {
+  term->normal_color = grub_term_normal_color;
+  term->highlight_color = grub_term_highlight_color;
+
   grub_list_push (GRUB_AS_LIST_P (&grub_term_outputs_disabled),
 		  GRUB_AS_LIST (term));
 }
@@ -297,6 +306,9 @@ static inline void
 grub_term_register_output_active (const char *name __attribute__ ((unused)),
 				  grub_term_output_t term)
 {
+  term->normal_color = grub_term_normal_color;
+  term->highlight_color = grub_term_highlight_color;
+
   if (! term->init || term->init (term) == GRUB_ERR_NONE)
     grub_list_push (GRUB_AS_LIST_P (&grub_term_outputs),
 		    GRUB_AS_LIST (term));

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2012-10-04 17:07 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-04 17:06 [PATCH] do not ignore current values for {normal,highlight}_color when loading terminal output module Andrey Borzenkov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.