Make color variables global instead of it being per-terminal.
This commit is contained in:
parent
7d8848f363
commit
bc1369732f
17 changed files with 83 additions and 79 deletions
|
@ -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 ();
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue