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
|
@ -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;
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
};
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
};
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
};
|
||||
|
||||
|
|
|
@ -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,
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue