Changed highlight state code for hercules, console and serial.
The state was 0 - normal or 1 - highlight. The state is now defined using an enum called color_state. * stage2/term.h (color_state): New enum. (COLOR_STATE_STANDARD): Standard color to use when not using user defined. (COLOR_STATE_NORMAL): User defined normal color. (COLOR_STATE_HIGHLIGHT): User defined highlight color. (console_highlight): Renamed to console_setcolorstate. (serial_highlight): Renamed to serial_setcolorstate. (hercules_highlight): Renamed to hercules_setcolorstate. * stage2/hercules.c (herc_highlight_state): Removed. (herc_standard_color): New variable. (herc_color_state): Likewise. (herc_highlight): Renamed to herc_setcolorstate. (herc_setcolorstate): Added switch to handle new states. * stage2/console.c (console_highlight_state): Removed. (console_standard_color): New variable. (console_color_state): Likewise. (console_highlight): Renamed to console_setcolorstate. (console_setcolorstate): Added switch to handle new states. * stage2/serial.c (serial_highlight): Renamed to serial_setcolorstate. (serial_setcolorstate): Adjusted 'if' to suit new states. * grub/asmstub.c (console_highlight): Renamed to console_setcolorstate. (console_setcolorstate): Adjusted 'if' to suit new states. * stage2/stage2.c (print_entry): Set color states using new states. (print_border): Likewise. * stage2/stage2.c (run_menu): Reverse if (!) to if () for uniformitty.
This commit is contained in:
parent
51955d52d8
commit
d932c071e9
8 changed files with 119 additions and 38 deletions
31
ChangeLog
31
ChangeLog
|
@ -1,3 +1,34 @@
|
|||
2002-09-20 Jason Thomas <jason@topic.com.au>
|
||||
|
||||
Changed highlight state code for hercules, console and serial.
|
||||
The state was 0 - normal or 1 - highlight.
|
||||
The state is now defined using an enum called color_state.
|
||||
|
||||
* stage2/term.h (color_state): New enum.
|
||||
(COLOR_STATE_STANDARD): Standard color to use when not using user defined.
|
||||
(COLOR_STATE_NORMAL): User defined normal color.
|
||||
(COLOR_STATE_HIGHLIGHT): User defined highlight color.
|
||||
(console_highlight): Renamed to console_setcolorstate.
|
||||
(serial_highlight): Renamed to serial_setcolorstate.
|
||||
(hercules_highlight): Renamed to hercules_setcolorstate.
|
||||
* stage2/hercules.c (herc_highlight_state): Removed.
|
||||
(herc_standard_color): New variable.
|
||||
(herc_color_state): Likewise.
|
||||
(herc_highlight): Renamed to herc_setcolorstate.
|
||||
(herc_setcolorstate): Added switch to handle new states.
|
||||
* stage2/console.c (console_highlight_state): Removed.
|
||||
(console_standard_color): New variable.
|
||||
(console_color_state): Likewise.
|
||||
(console_highlight): Renamed to console_setcolorstate.
|
||||
(console_setcolorstate): Added switch to handle new states.
|
||||
* stage2/serial.c (serial_highlight): Renamed to serial_setcolorstate.
|
||||
(serial_setcolorstate): Adjusted 'if' to suit new states.
|
||||
* grub/asmstub.c (console_highlight): Renamed to console_setcolorstate.
|
||||
(console_setcolorstate): Adjusted 'if' to suit new states.
|
||||
* stage2/stage2.c (print_entry): Set color states using new states.
|
||||
(print_border): Likewise.
|
||||
* stage2/stage2.c (run_menu): Reverse if (!) to if () for uniformitty.
|
||||
|
||||
2002-07-12 Yoshinori K. Okuji <okuji@enbug.org>
|
||||
|
||||
* stage2/boot.c (load_image): Rewrite the Linux booting support
|
||||
|
|
|
@ -727,9 +727,10 @@ console_cls (void)
|
|||
}
|
||||
|
||||
void
|
||||
console_highlight (int state)
|
||||
console_setcolorstate (color_state state)
|
||||
{
|
||||
console_current_color = state ? A_REVERSE : A_NORMAL;
|
||||
console_current_color =
|
||||
(state == COLOR_STATE_HIGHLIGHT) ? A_REVERSE : A_NORMAL;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1250,9 +1251,9 @@ hercules_cls (void)
|
|||
}
|
||||
|
||||
void
|
||||
hercules_highlight (int state)
|
||||
hercules_setcolorstate (color_state state)
|
||||
{
|
||||
console_highlight (state);
|
||||
console_setcolorstate (state);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -41,7 +41,7 @@ struct term_entry term_table[] =
|
|||
console_getxy,
|
||||
console_gotoxy,
|
||||
console_cls,
|
||||
console_highlight,
|
||||
console_setcolorstate,
|
||||
console_setcolor,
|
||||
console_nocursor
|
||||
},
|
||||
|
@ -56,7 +56,7 @@ struct term_entry term_table[] =
|
|||
serial_getxy,
|
||||
serial_gotoxy,
|
||||
serial_cls,
|
||||
serial_highlight,
|
||||
serial_setcolorstate,
|
||||
0,
|
||||
0
|
||||
},
|
||||
|
@ -71,7 +71,7 @@ struct term_entry term_table[] =
|
|||
hercules_getxy,
|
||||
hercules_gotoxy,
|
||||
hercules_cls,
|
||||
hercules_highlight,
|
||||
hercules_setcolorstate,
|
||||
hercules_setcolor,
|
||||
hercules_nocursor
|
||||
},
|
||||
|
@ -1028,13 +1028,13 @@ grub_putchar (int c)
|
|||
the following grub_printf call will print newlines. */
|
||||
count_lines = -1;
|
||||
|
||||
if (current_term->highlight)
|
||||
current_term->highlight (1);
|
||||
if (current_term->setcolorstate)
|
||||
current_term->setcolorstate (COLOR_STATE_HIGHLIGHT);
|
||||
|
||||
grub_printf ("\n[Hit return to continue]");
|
||||
|
||||
if (current_term->highlight)
|
||||
current_term->highlight (0);
|
||||
if (current_term->setcolorstate)
|
||||
current_term->setcolorstate (COLOR_STATE_NORMAL);
|
||||
|
||||
do
|
||||
{
|
||||
|
|
|
@ -26,16 +26,30 @@
|
|||
console_gotoxy, console_cls, and console_nocursor. */
|
||||
|
||||
int console_current_color = A_NORMAL;
|
||||
static int console_standard_color = A_NORMAL;
|
||||
static int console_normal_color = A_NORMAL;
|
||||
static int console_highlight_color = A_REVERSE;
|
||||
static int console_highlight_state = 0;
|
||||
static color_state console_color_state = COLOR_STATE_STANDARD;
|
||||
|
||||
void
|
||||
console_highlight (int state)
|
||||
console_setcolorstate (color_state state)
|
||||
{
|
||||
console_current_color
|
||||
= state ? console_highlight_color : console_normal_color;
|
||||
console_highlight_state = state;
|
||||
switch (state) {
|
||||
case COLOR_STATE_STANDARD:
|
||||
console_current_color = console_standard_color;
|
||||
break;
|
||||
case COLOR_STATE_NORMAL:
|
||||
console_current_color = console_normal_color;
|
||||
break;
|
||||
case COLOR_STATE_HIGHLIGHT:
|
||||
console_current_color = console_highlight_color;
|
||||
break;
|
||||
default:
|
||||
console_current_color = console_standard_color;
|
||||
break;
|
||||
}
|
||||
|
||||
console_color_state = state;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -44,5 +58,5 @@ console_setcolor (int normal_color, int highlight_color)
|
|||
console_normal_color = normal_color;
|
||||
console_highlight_color = highlight_color;
|
||||
|
||||
console_highlight (console_highlight_state);
|
||||
console_setcolorstate (console_color_state);
|
||||
}
|
||||
|
|
|
@ -28,10 +28,11 @@
|
|||
static int herc_x;
|
||||
static int herc_y;
|
||||
|
||||
static int herc_standard_color = A_NORMAL;
|
||||
static int herc_normal_color = A_NORMAL;
|
||||
static int herc_highlight_color = A_REVERSE;
|
||||
static int herc_current_color = A_NORMAL;
|
||||
static int herc_highlight_state = 0;
|
||||
static color_state herc_color_state = COLOR_STATE_STANDARD;
|
||||
|
||||
/* Write a byte to a port. */
|
||||
static inline void
|
||||
|
@ -148,10 +149,24 @@ hercules_gotoxy (int x, int y)
|
|||
}
|
||||
|
||||
void
|
||||
hercules_highlight (int state)
|
||||
hercules_setcolorstate (color_state state)
|
||||
{
|
||||
herc_current_color = state ? herc_highlight_color : herc_normal_color;
|
||||
herc_highlight_state = state;
|
||||
switch (state) {
|
||||
case COLOR_STATE_STANDARD:
|
||||
herc_current_color = herc_standard_color;
|
||||
break;
|
||||
case COLOR_STATE_NORMAL:
|
||||
herc_current_color = herc_normal_color;
|
||||
break;
|
||||
case COLOR_STATE_HIGHLIGHT:
|
||||
herc_current_color = herc_highlight_color;
|
||||
break;
|
||||
default:
|
||||
herc_current_color = herc_standard_color;
|
||||
break;
|
||||
}
|
||||
|
||||
herc_color_state = state;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -160,7 +175,7 @@ hercules_setcolor (int normal_color, int highlight_color)
|
|||
herc_normal_color = normal_color;
|
||||
herc_highlight_color = highlight_color;
|
||||
|
||||
hercules_highlight (herc_highlight_state);
|
||||
hercules_setcolorstate (herc_color_state);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -414,10 +414,10 @@ serial_cls (void)
|
|||
}
|
||||
|
||||
void
|
||||
serial_highlight (int state)
|
||||
serial_setcolorstate (color_state state)
|
||||
{
|
||||
keep_track = 0;
|
||||
grub_printf ("\e[%cm", state ? '7' : '0');
|
||||
grub_printf ("\e[%cm", (state == COLOR_STATE_HIGHLIGHT) ? '7' : '0');
|
||||
keep_track = 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -98,11 +98,12 @@ static void
|
|||
print_entry (int y, int highlight, char *entry)
|
||||
{
|
||||
int x;
|
||||
|
||||
if (current_term->setcolorstate)
|
||||
current_term->setcolorstate (COLOR_STATE_NORMAL);
|
||||
|
||||
highlight = (highlight && current_term->highlight);
|
||||
|
||||
if (highlight)
|
||||
current_term->highlight (1);
|
||||
if (highlight && current_term->setcolorstate)
|
||||
current_term->setcolorstate (COLOR_STATE_HIGHLIGHT);
|
||||
|
||||
gotoxy (2, y);
|
||||
grub_putchar (' ');
|
||||
|
@ -115,8 +116,8 @@ print_entry (int y, int highlight, char *entry)
|
|||
}
|
||||
gotoxy (74, y);
|
||||
|
||||
if (highlight)
|
||||
current_term->highlight (0);
|
||||
if (current_term->setcolorstate)
|
||||
current_term->setcolorstate (COLOR_STATE_STANDARD);
|
||||
}
|
||||
|
||||
/* Print entries in the menu box. */
|
||||
|
@ -186,6 +187,9 @@ static void
|
|||
print_border (int y, int size)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (current_term->setcolorstate)
|
||||
current_term->setcolorstate (COLOR_STATE_NORMAL);
|
||||
|
||||
gotoxy (1, y);
|
||||
|
||||
|
@ -213,6 +217,9 @@ print_border (int y, int size)
|
|||
for (i = 0; i < 73; i++)
|
||||
grub_putchar (DISP_HORIZ);
|
||||
grub_putchar (DISP_LR);
|
||||
|
||||
if (current_term->setcolorstate)
|
||||
current_term->setcolorstate (COLOR_STATE_STANDARD);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -287,10 +294,10 @@ restart:
|
|||
init_page ();
|
||||
nocursor ();
|
||||
|
||||
if (! (current_term->flags & TERM_DUMB))
|
||||
print_border (3, 12);
|
||||
else
|
||||
if (current_term->flags & TERM_DUMB)
|
||||
print_entries_raw (num_entries, first_entry, menu_entries);
|
||||
else
|
||||
print_border (3, 12);
|
||||
|
||||
grub_printf ("\n\
|
||||
Use the %c and %c keys to select which entry is highlighted.\n",
|
||||
|
|
|
@ -21,6 +21,19 @@
|
|||
#ifndef GRUB_TERM_HEADER
|
||||
#define GRUB_TERM_HEADER 1
|
||||
|
||||
/* These are used to represent the various color states we use */
|
||||
typedef enum
|
||||
{
|
||||
/* represents the color used to display all text that does not use the user
|
||||
* defined colors below
|
||||
*/
|
||||
COLOR_STATE_STANDARD,
|
||||
/* represents the user defined colors for normal text */
|
||||
COLOR_STATE_NORMAL,
|
||||
/* represents the user defined colors for highlighted text */
|
||||
COLOR_STATE_HIGHLIGHT
|
||||
} color_state;
|
||||
|
||||
#ifndef STAGE1_5
|
||||
|
||||
/* Flags for representing the capabilities of a terminal. */
|
||||
|
@ -59,8 +72,8 @@ struct term_entry
|
|||
void (*gotoxy) (int x, int y);
|
||||
/* Clear the screen. */
|
||||
void (*cls) (void);
|
||||
/* Highlight characters written after this call, if STATE is true. */
|
||||
void (*highlight) (int state);
|
||||
/* Set the current color to be used */
|
||||
void (*setcolorstate) (color_state state);
|
||||
/* Set the normal color and the highlight color. The format of each
|
||||
color is VGA's. */
|
||||
void (*setcolor) (int normal_color, int highlight_color);
|
||||
|
@ -86,7 +99,7 @@ int console_getkey (void);
|
|||
int console_getxy (void);
|
||||
void console_gotoxy (int x, int y);
|
||||
void console_cls (void);
|
||||
void console_highlight (int state);
|
||||
void console_setcolorstate (color_state state);
|
||||
void console_setcolor (int normal_color, int highlight_color);
|
||||
void console_nocursor (void);
|
||||
#endif
|
||||
|
@ -98,7 +111,7 @@ int serial_getkey (void);
|
|||
int serial_getxy (void);
|
||||
void serial_gotoxy (int x, int y);
|
||||
void serial_cls (void);
|
||||
void serial_highlight (int state);
|
||||
void serial_setcolorstate (color_state state);
|
||||
#endif
|
||||
|
||||
#ifdef SUPPORT_HERCULES
|
||||
|
@ -106,7 +119,7 @@ void hercules_putchar (int c);
|
|||
int hercules_getxy (void);
|
||||
void hercules_gotoxy (int x, int y);
|
||||
void hercules_cls (void);
|
||||
void hercules_highlight (int state);
|
||||
void hercules_setcolorstate (color_state state);
|
||||
void hercules_setcolor (int normal_color, int highlight_color);
|
||||
void hercules_nocursor (void);
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue