diff --git a/ChangeLog b/ChangeLog index 15175d479..b02d096dc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,25 @@ +1999-06-08 OKUJI Yoshinori + + Color-menu support based on Peter Astrand + 's patch. + + * shared_src/asm.S (nocursor): New function. + * shared_src/cmdline.c (normal_color): New variable. + (highlight_color): Likewise. + (commands): Added "color" command. + (enter_cmdline): Handle the color command. + * shared_src/shared.h (normal_color): Declared. + (highlight_color): Likewise. + [!GRUB_UTIL] (nocursor): Likewise. + * shared_src/stage2.c (print_border) [!GRUB_UTIL]: Color the + menu. + (run_menu) [!GRUB_UTIL]: Call nocursor, and call set_line with + the second argument HIGHLIGHT_COLOR when highlighting a line, + and NORMAL_COLOR when drawing a normal line. + (cmain): Initialize normal_color and highlight_color. Handle + the color command in the same way as the command-line + interface. + 1999-06-07 OKUJI Yoshinori * e2fs_stage1_5/Makefile.am (IMPORTANT_SIZE_LIMIT): Set to 31744. diff --git a/NEWS b/NEWS index 4a3a41c45..a51723550 100644 --- a/NEWS +++ b/NEWS @@ -10,6 +10,7 @@ New: characters. * stage2_debug is removed, and the debugging features are added into stage2. +* Color menu support. New in 0.5.91 - 1999-03-14, Gordon Matzigkeit: * LBA and preliminary AWARD BIOS disk extension support. diff --git a/THANKS b/THANKS index 122b447cc..363fce53c 100644 --- a/THANKS +++ b/THANKS @@ -16,4 +16,5 @@ Kunihiro Ishiguro Miles Bader OKUJI Yoshinori Pavel Roskin +Peter Astrand VaX#n8 diff --git a/docs/grub.texi b/docs/grub.texi index 0da4f5002..97ef1fe38 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -745,12 +745,87 @@ PC partitions. This boots the OS/chain-loader which has been loaded. Only necessary if running the fully interactive command-line (it is implicit at the end of a config-file entry). + +@item color= @var{normal} [@var{highlight}] +Change the menu colors. The color @var{normal} is used for the normal +line in the menu, and the color @var{highlight} is used to highlight the +line where the cursor points to. If you omit @var{highlight}, then the +inverted color of @var{normal} is used for the highlighted line. You +must specify an integer for a color value, and the 0-3 bits represents +the foreground color, the 4-6 bits represents the background color, and +the 7 bit represents that the foreground blinks. + +These are the possible values and the meanings: + +@table @asis +@item 0 +black + +@item 1 +blue + +@item 2 +green + +@item 3 +cyan + +@item 4 +red + +@item 5 +magenta + +@item 6 +brown + +@item 7 +light gray + +@item +@strong{These below can be specified only for the foreground.} + +@item 8 +dark gray + +@item 9 +light blue + +@item A +light green + +@item B +light cyan + +@item C +light red + +@item D +light magenta + +@item E +yellow + +@item F +white @end table -Commands usable in configuration files and interactively which are only -available in the debug version of the GRUB Stage 2. +The background is represented by 3 bits, so you cannot specify more than +7 for it. + +This command can be used in the configuration file and on the +command-line, so you may write something like this in your configuration +file: + +@example +# the default colors (light gray / blue, black / light gray) +color= 0x17 0x70 + +# change the colors +title= OS-BS like +color= 0x16 0x60 +@end example -@table @code @item testload= @var{file} Read the entire contents of @var{file} in several different ways and compares them, to test the filesystem code. The output is somewhat diff --git a/shared_src/asm.S b/shared_src/asm.S index c523e8b4b..9f5f7feba 100644 --- a/shared_src/asm.S +++ b/shared_src/asm.S @@ -1133,6 +1133,38 @@ ENTRY(cls) pop %ebp ret + +/* + * nocursor() + * BIOS call "INT 10H Function 01h" to set cursor type + * Call with %ah = 0x01 + * %ch = cursor starting scanline + * %cl = cursor ending scanline + */ + +ENTRY(nocursor) + push %ebp + push %eax + push %ebx /* save EBX */ + push %edx + + call EXT_C(prot_to_real) + .code16 + + movw $0x2000, %cx + movb $0x1, %ah + int $0x10 + + data32 + call EXT_C(real_to_prot) + .code32 + + pop %edx + pop %ebx + pop %eax + pop %ebp + ret + /* * getxy() diff --git a/shared_src/cmdline.c b/shared_src/cmdline.c index df67421d2..e2fd0c769 100644 --- a/shared_src/cmdline.c +++ b/shared_src/cmdline.c @@ -78,6 +78,10 @@ char *password; /* True when the debug mode is turned on, and false when it is turned off. */ int debug = 0; +/* Color settings */ +int normal_color; +int highlight_color; + char * skip_to(int after_equal, char *cmdline) { @@ -107,7 +111,7 @@ char commands[] = \"rootnoverify= \", \"chainloader= \", \"kernel= ...\", \"testload= \", \"read= \", \"displaymem\", \"impsprobe\", \"fstest\", \"debug\", \"module= ...\", \"modulenounzip= ...\", - \"makeactive\", \"boot\", and + \"color= []\", \"makeactive\", \"boot\", and \"install= [d] [p] []\"\n"; static void @@ -632,8 +636,26 @@ returnit: grub_printf (" Debug mode is turned on\n"); } } + else if (substring ("color", cur_heap) < 1) + { + char *normal; + char *highlight; + + normal = cur_cmdline; + highlight = skip_to (0, normal); + + if (safe_parse_maxint (&normal, &normal_color)) + { + /* The second argument is optional, so set highlight_color + to inverted NORMAL_COLOR. */ + if (*highlight == 0 + || ! safe_parse_maxint (&highlight, &highlight_color)) + highlight_color = ((normal_color >> 4) + | ((normal_color & 0xf) << 4)); + } + } else if (*cur_heap && *cur_heap != ' ') errnum = ERR_UNRECOGNIZED; - + goto restart; } diff --git a/shared_src/shared.h b/shared_src/shared.h index 6c1f207b3..f0f66542f 100644 --- a/shared_src/shared.h +++ b/shared_src/shared.h @@ -312,6 +312,8 @@ extern void (*debug_fs) (int); extern void (*debug_fs_func) (int); /* The flag for debug mode. */ extern int debug; +/* Color settings */ +extern int normal_color, highlight_color; #endif /* STAGE1_5 */ extern unsigned long current_drive; @@ -425,6 +427,11 @@ int getrtsecs (void); /* Clear the screen. */ void cls (void); +#ifndef GRUB_UTIL +/* Turn off cursor. */ +void nocursor (void); +#endif + /* Get the current cursor position (where 0,0 is the top left hand corner of the screen). Returns packed values, (RET >> 8) is x, (RET & 0xff) is y. */ diff --git a/shared_src/stage2.c b/shared_src/stage2.c index efe7258d7..5602537df 100644 --- a/shared_src/stage2.c +++ b/shared_src/stage2.c @@ -89,6 +89,19 @@ print_border(int y, int size) { int i; +#ifndef GRUB_UTIL + /* Color the menu. The menu is 75 * 14 characters. */ + for (i = 0; i < 14; i++) + { + int j; + for (j = 0; j < 75; j++) + { + gotoxy (j + 1, i + y); + set_attrib (normal_color); + } + } +#endif + gotoxy(1, y); putchar(DISP_UL); @@ -152,6 +165,9 @@ restart: } init_page(); +#ifndef GRUB_UTIL + nocursor(); +#endif print_border(3, 12); @@ -178,8 +194,13 @@ restart: print_entries(3, 12, first_entry, menu_entries); - /* invert initial line */ + /* highlight initial line */ +#ifdef GRUB_UTIL set_line (4 + entryno, A_REVERSE); +#else + set_line (4 + entryno, highlight_color); +#endif + /* XX using RT clock now, need to initialize value */ while ((time1 = getrtsecs()) == 0xFF); @@ -222,15 +243,27 @@ restart: { if (entryno > 0) { +#ifdef GRUB_UTIL set_line (4 + entryno, A_NORMAL); +#else + set_line (4 + entryno, normal_color); +#endif entryno --; +#ifdef GRUB_UTIL set_line (4 + entryno, A_REVERSE); +#else + set_line (4 + entryno, highlight_color); +#endif } else if (first_entry > 0) { first_entry --; print_entries(3, 12, first_entry, menu_entries); +#ifdef GRUB_UTIL set_line (4, A_REVERSE); +#else + set_line (4, highlight_color); +#endif } } if (((c == KEY_DOWN) || (ASCII_CHAR(c) == 14)) @@ -238,15 +271,27 @@ restart: { if (entryno < 11) { +#ifdef GRUB_UTIL set_line (4 + entryno, A_NORMAL); +#else + set_line (4 + entryno, normal_color); +#endif entryno ++; +#ifdef GRUB_UTIL set_line (4 + entryno, A_REVERSE); +#else + set_line (4 + entryno, highlight_color); +#endif } else if (num_entries > 12+first_entry) { first_entry ++; print_entries (3, 12, first_entry, menu_entries); +#ifdef GRUB_UTIL set_line (15, A_REVERSE); +#else + set_line (15, highlight_color); +#endif } } @@ -261,7 +306,11 @@ restart: { if ((c == 'd') || (c == 'o') || (c == 'O')) { +#ifdef GRUB_UTIL set_line (4 + entryno, A_NORMAL); +#else + set_line (4 + entryno, normal_color); +#endif /* insert after is almost exactly like insert before */ if (c == 'o') { @@ -518,7 +567,12 @@ cmain(void) for (;;) { - config_len = 0; menu_len = 0; num_entries = 0; default_entry = 0; + config_len = 0; + menu_len = 0; + num_entries = 0; + default_entry = 0; + normal_color = A_NORMAL; + highlight_color = A_REVERSE; config_entries = (char *)(mbi.mmap_addr + mbi.mmap_length); menu_entries = (char *)(BUFFERADDR + (32 * 1024)); password = NULL; fallback = -1; grub_timeout = -1; @@ -562,13 +616,30 @@ cmain(void) } else if (!state) { - if (substring("timeout", cmdline) < 1) - safe_parse_maxint(&ptr, &grub_timeout); - if (substring("fallback", cmdline) < 1) - safe_parse_maxint(&ptr, &fallback); - if (substring("default", cmdline) < 1) - safe_parse_maxint(&ptr, &default_entry); - if (substring("password", cmdline) < 1) + if (substring ("timeout", cmdline) < 1) + safe_parse_maxint (&ptr, &grub_timeout); + else if (substring ("fallback", cmdline) < 1) + safe_parse_maxint (&ptr, &fallback); + else if (substring ("default", cmdline) < 1) + safe_parse_maxint (&ptr, &default_entry); + else if (substring ("color", cmdline) < 1) + { + char *normal; + char *highlight; + + normal = ptr; + highlight = skip_to (0, normal); + + if (safe_parse_maxint (&normal, &normal_color)) + { + if (*highlight == 0 + || ! safe_parse_maxint (&highlight, + &highlight_color)) + highlight_color = ((normal_color >> 4) + | ((normal_color & 0xf) << 4)); + } + } + else if (substring ("password", cmdline) < 1) { password = config_entries; while ((*(config_entries++) = *(ptr++)) != 0);