2007-12-25 Robert Millan <rmh@aybabtu.com>

* include/grub/term.h (struct grub_term): Add `getcolor' function.
	(grub_getcolor): New function.

	* kern/term.c (grub_getcolor): New function.
	* normal/menu.c (GRUB_COLOR_MENU_NORMAL): New macro.
	(GRUB_COLOR_MENU_HIGHLIGHT): New macro.
	(print_entry): Set normal and highlight colors to
	`GRUB_COLOR_MENU_NORMAL' and `GRUB_COLOR_MENU_HIGHLIGHT',
	respectively, before printing and restore them to old
	values afterwards.
	(grub_menu_init_page): Likewise.  Fill an additional colored space
	that would otherwise be left blank.

	* term/efi/console.c (grub_console_getcolor): New function.
	(struct grub_console_term.getcolor): New variable.
	* term/i386/pc/console.c (grub_console_getcolor): New function.
	(struct grub_console_term.getcolor): New variable.
	* term/ieee1275/ofconsole.c (grub_ofconsole_getcolor): New function.
	(struct grub_console_term.getcolor): New variable.

	* term/i386/pc/serial.c (grub_serial_setcolor): Remove function.
	(struct grub_console_term.setcolor): Remove variable.
	* term/i386/pc/vesafb.c (grub_virtual_screen_setcolor): Remove function.
	(struct grub_console_term.setcolor): Remove variable.
	* term/i386/pc/vga.c (grub_vga_setcolor): Remove function.
	(struct grub_console_term.setcolor): Remove variable.
	* term/gfxterm.c (grub_virtual_screen_setcolor): Remove function.
	(struct grub_console_term.setcolor): Remove variable.
This commit is contained in:
robertmh 2007-12-25 11:10:47 +00:00
parent 4931827fe4
commit 533110ada7
11 changed files with 85 additions and 34 deletions

View file

@ -25,6 +25,9 @@
#include <grub/env.h>
#include <grub/script.h>
#define GRUB_COLOR_MENU_NORMAL 0x07
#define GRUB_COLOR_MENU_HIGHLIGHT 0x70
static void
draw_border (void)
{
@ -105,7 +108,8 @@ 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;
title = entry ? entry->title : "";
unicode_title = grub_malloc (grub_strlen (title) * sizeof (*unicode_title));
if (! unicode_title)
@ -121,6 +125,8 @@ print_entry (int y, int highlight, grub_menu_entry_t entry)
return;
}
grub_getcolor (&normal_code, &highlight_code);
grub_setcolor (GRUB_COLOR_MENU_NORMAL, GRUB_COLOR_MENU_HIGHLIGHT);
grub_setcolorstate (highlight
? GRUB_TERM_COLOR_HIGHLIGHT
: GRUB_TERM_COLOR_NORMAL);
@ -153,8 +159,12 @@ print_entry (int y, int highlight, grub_menu_entry_t entry)
x++;
}
}
grub_setcolorstate (GRUB_TERM_COLOR_NORMAL);
grub_putchar (' ');
grub_gotoxy (GRUB_TERM_CURSOR_X, y);
grub_setcolor (normal_code, highlight_code);
grub_setcolorstate (GRUB_TERM_COLOR_STANDARD);
grub_free (unicode_title);
}
@ -199,9 +209,15 @@ 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_normal_init_page ();
draw_border ();
print_message (nested, edit);
grub_setcolor (normal_code, highlight_code);
}
/* Return the current timeout. If the variable "timeout" is not set or