2008-01-05 Robert Millan <rmh@aybabtu.com>
* include/grub/normal.h (grub_env_write_color_normal): New prototype. (grub_env_write_color_highlight): Likewise. (grub_wait_after_message): Likewise. * normal/color.c: New file. * conf/i386-pc.rmk (grub_emu_SOURCES): Add `normal/color.c'. (normal_mod_DEPENDENCIES): Likewise. * conf/i386-efi.rmk (grub_emu_SOURCES): Add `normal/color.c'. (normal_mod_DEPENDENCIES): Likewise. * conf/i386-linuxbios.rmk (grub_emu_SOURCES): Add `normal/color.c'. (normal_mod_DEPENDENCIES): Likewise. * conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Add `normal/color.c'. (normal_mod_DEPENDENCIES): Likewise. * normal/menu_entry.c (run): Rely on grub_wait_after_message() for waiting after a message is printed. * normal/main.c (read_config_file): Likewise. (grub_normal_init): Register grub_env_write_color_normal() and grub_env_write_color_highlight() hooks. Mark `color_normal' and `color_highlight' variables as global. * normal/menu.c (grub_wait_after_message): New function. (grub_color_menu_normal): New variable. Replaces ... (GRUB_COLOR_MENU_NORMAL): ... this macro. (grub_color_menu_highlight): New variable. Replaces ... (GRUB_COLOR_MENU_HIGHLIGHT): ... this macro. (draw_border): Set color state to `GRUB_TERM_COLOR_NORMAL' instead of `GRUB_TERM_COLOR_STANDARD'. (print_message): Use `grub_setcolorstate' to reload colors. Rename `normal_code' and `highlight_code' to `old_color_normal' and `old_color_highlight', respectively. (grub_menu_init_page): Update colors when drawing the menu, based on `menu_color_normal' and `menu_color_highlight' variables. (grub_menu_run): Rely on grub_wait_after_message() for waiting after a message is printed.
This commit is contained in:
parent
182dd4e568
commit
0ece25b1e1
13 changed files with 188 additions and 62 deletions
|
@ -1,7 +1,7 @@
|
|||
/* main.c - the normal mode main routine */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2000,2001,2002,2003,2005,2006,2007 Free Software Foundation, Inc.
|
||||
* Copyright (C) 2000,2001,2002,2003,2005,2006,2007,2008 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -268,12 +268,7 @@ read_config_file (const char *config, int nested)
|
|||
grub_file_close (file);
|
||||
|
||||
if (errors > 0)
|
||||
{
|
||||
/* Wait until the user pushes any key so that the user can
|
||||
see what happened. */
|
||||
grub_printf ("\nPress any key to continue...");
|
||||
(void) grub_getkey ();
|
||||
}
|
||||
grub_wait_after_message ();
|
||||
|
||||
return newmenu;
|
||||
}
|
||||
|
@ -527,6 +522,14 @@ GRUB_MOD_INIT(normal)
|
|||
grub_rescue_register_command ("normal", grub_rescue_cmd_normal,
|
||||
"enter normal mode");
|
||||
|
||||
/* Reload terminal colors when these variables are written to. */
|
||||
grub_register_variable_hook ("color_normal", NULL, grub_env_write_color_normal);
|
||||
grub_register_variable_hook ("color_highlight", NULL, grub_env_write_color_highlight);
|
||||
|
||||
/* Preserve hooks after context changes. */
|
||||
grub_env_export ("color_normal");
|
||||
grub_env_export ("color_highlight");
|
||||
|
||||
/* This registers some built-in commands. */
|
||||
grub_command_init ();
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2003,2004,2005,2006,2007 Free Software Foundation, Inc.
|
||||
* Copyright (C) 2003,2004,2005,2006,2007,2008 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -25,8 +25,17 @@
|
|||
#include <grub/env.h>
|
||||
#include <grub/script.h>
|
||||
|
||||
#define GRUB_COLOR_MENU_NORMAL 0x07
|
||||
#define GRUB_COLOR_MENU_HIGHLIGHT 0x70
|
||||
static grub_uint8_t grub_color_menu_normal;
|
||||
static grub_uint8_t grub_color_menu_highlight;
|
||||
|
||||
/* Wait until the user pushes any key so that the user
|
||||
can see what happened. */
|
||||
void
|
||||
grub_wait_after_message (void)
|
||||
{
|
||||
grub_printf ("\nPress any key to continue...");
|
||||
(void) grub_getkey ();
|
||||
}
|
||||
|
||||
static void
|
||||
draw_border (void)
|
||||
|
@ -57,7 +66,7 @@ draw_border (void)
|
|||
grub_putcode (GRUB_TERM_DISP_HLINE);
|
||||
grub_putcode (GRUB_TERM_DISP_LR);
|
||||
|
||||
grub_setcolorstate (GRUB_TERM_COLOR_STANDARD);
|
||||
grub_setcolorstate (GRUB_TERM_COLOR_NORMAL);
|
||||
|
||||
grub_gotoxy (GRUB_TERM_MARGIN,
|
||||
(GRUB_TERM_TOP_BORDER_Y + GRUB_TERM_NUM_ENTRIES
|
||||
|
@ -67,6 +76,8 @@ draw_border (void)
|
|||
static void
|
||||
print_message (int nested, int edit)
|
||||
{
|
||||
grub_setcolorstate (GRUB_TERM_COLOR_NORMAL);
|
||||
|
||||
if (edit)
|
||||
{
|
||||
grub_printf ("\n\
|
||||
|
@ -108,7 +119,7 @@ print_entry (int y, int highlight, grub_menu_entry_t entry)
|
|||
grub_ssize_t len;
|
||||
grub_uint32_t *unicode_title;
|
||||
grub_ssize_t i;
|
||||
grub_uint8_t normal_code, highlight_code;
|
||||
grub_uint8_t old_color_normal, old_color_highlight;
|
||||
|
||||
title = entry ? entry->title : "";
|
||||
unicode_title = grub_malloc (grub_strlen (title) * sizeof (*unicode_title));
|
||||
|
@ -124,9 +135,9 @@ print_entry (int y, int highlight, grub_menu_entry_t entry)
|
|||
grub_free (unicode_title);
|
||||
return;
|
||||
}
|
||||
|
||||
grub_getcolor (&normal_code, &highlight_code);
|
||||
grub_setcolor (GRUB_COLOR_MENU_NORMAL, GRUB_COLOR_MENU_HIGHLIGHT);
|
||||
|
||||
grub_getcolor (&old_color_normal, &old_color_highlight);
|
||||
grub_setcolor (grub_color_menu_normal, grub_color_menu_highlight);
|
||||
grub_setcolorstate (highlight
|
||||
? GRUB_TERM_COLOR_HIGHLIGHT
|
||||
: GRUB_TERM_COLOR_NORMAL);
|
||||
|
@ -164,8 +175,8 @@ print_entry (int y, int highlight, grub_menu_entry_t entry)
|
|||
|
||||
grub_gotoxy (GRUB_TERM_CURSOR_X, y);
|
||||
|
||||
grub_setcolor (normal_code, highlight_code);
|
||||
grub_setcolorstate (GRUB_TERM_COLOR_STANDARD);
|
||||
grub_setcolor (old_color_normal, old_color_highlight);
|
||||
grub_setcolorstate (GRUB_TERM_COLOR_NORMAL);
|
||||
grub_free (unicode_title);
|
||||
}
|
||||
|
||||
|
@ -209,15 +220,23 @@ print_entries (grub_menu_t menu, int first, int offset)
|
|||
void
|
||||
grub_menu_init_page (int nested, int edit)
|
||||
{
|
||||
grub_uint8_t normal_code, highlight_code;
|
||||
grub_getcolor (&normal_code, &highlight_code);
|
||||
grub_setcolor (GRUB_COLOR_MENU_NORMAL, GRUB_COLOR_MENU_HIGHLIGHT);
|
||||
grub_uint8_t old_color_normal, old_color_highlight;
|
||||
|
||||
grub_getcolor (&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;
|
||||
|
||||
/* Then give user a chance to replace them. */
|
||||
grub_parse_color_name_pair (&grub_color_menu_normal, grub_env_get ("menu_color_normal"));
|
||||
grub_parse_color_name_pair (&grub_color_menu_highlight, grub_env_get ("menu_color_highlight"));
|
||||
|
||||
grub_normal_init_page ();
|
||||
grub_setcolor (grub_color_menu_normal, grub_color_menu_highlight);
|
||||
draw_border ();
|
||||
grub_setcolor (old_color_normal, old_color_highlight);
|
||||
print_message (nested, edit);
|
||||
|
||||
grub_setcolor (normal_code, highlight_code);
|
||||
}
|
||||
|
||||
/* Return the current timeout. If the variable "timeout" is not set or
|
||||
|
@ -501,10 +520,7 @@ grub_menu_run (grub_menu_t menu, int nested)
|
|||
grub_print_error ();
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
|
||||
/* Wait until the user pushes any key so that the user
|
||||
can see what happened. */
|
||||
grub_printf ("\nPress any key to continue...");
|
||||
(void) grub_getkey ();
|
||||
grub_wait_after_message ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2005,2006,2007 Free Software Foundation, Inc.
|
||||
* Copyright (C) 2005,2006,2007,2008 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -1030,10 +1030,7 @@ run (struct screen *screen)
|
|||
{
|
||||
grub_print_error ();
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
/* Wait until the user pushes any key so that the user
|
||||
can see what happened. */
|
||||
grub_printf ("\nPress any key to continue...");
|
||||
(void) grub_getkey ();
|
||||
grub_wait_after_message ();
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue