I've modified my patch. If no color-options are added to menu.lst, Grub
looks exactly as normal. Two new commands are added:
-- "menucolor= <num>"
Sets the color attributes of menu background and text.
-- "reversecolor= <num>"
Sets the attributes for the highlighted line.
These commands works both in menu.lst and via the commandline. This also
means that one can try out color-schemes by using a menu.lst with
different color-commands, like:
# menu.lst to try out colors
title=Blue background / Lightgray foreground
menucolor=0x17
reversecolor=0x70
title=Magenta background / White foreground
menucolor=0x5f
reversecolor=0x7f
Here is the patch:
diff -u4 -r --new-file --exclude-from=diffexclude cvsgrub/docs/colors.txt
grub/docs/colors.txt
--- cvsgrub/docs/colors.txt Thu Jan 1 01:00:00 1970
+++ grub/docs/colors.txt Sun Jun 6 22:04:30 1999
@@ -0,0 +1,63 @@
+
+ Setting the menu color
+
+
+You can change the menu color by using two commands in the config file:
+
+ -- "menucolor= <num>"
+ Sets the color attributes of menu background and text.
+
+ -- "reversecolor= <num>"
+ Sets the attributes for the highlighted line.
+
+These values are the valid colors if <num> is 0xMN:
+
+M=background
+------------
+0 = black
+1 = blue
+2 = green
+3 = cyan
+4 = red
+5 = magenta
+6 = brown
+7 = light gray
+
+Add 8 for foreground blink.
+
+N=foreground
+------------
+0 = black
+1 = blue
+2 = green
+3 = cyan
+4 = red
+5 = magenta
+6 = brown
+7 = light gray
+8 = dark gray
+9 = light blue
+A = light green
+B = light cyan
+C = light red
+D = light magenta
+E = yellow
+F = white
+
+
+For example, setting menucolor=0x17 selects the same colors as OS/2 boot
+manager. You can also use these commands i menu.lst. Example:
+
+# menu.lst to try out colors
+title=Blue background / Lightgray foreground
+menucolor=0x17
+reversecolor=0x70
+
+title=Magenta background / White foreground
+menucolor=0x5f
+reversecolor=0x7f
+
+
+
+
+
diff -u4 -r --new-file --exclude-from=diffexclude cvsgrub/shared_src/asm.S
grub/shared_src/asm.S
--- cvsgrub/shared_src/asm.S Sun Jun 6 03:40:53 1999
+++ grub/shared_src/asm.S Sun Jun 6 13:52:47 1999
@@ -1132,8 +1132,40 @@
pop %eax
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()
* BIOS call "INT 10H Function 03h" to get cursor position
diff -u4 -r --new-file --exclude-from=diffexclude cvsgrub/shared_src/cmdline.c
grub/shared_src/cmdline.c
--- cvsgrub/shared_src/cmdline.c Sun Jun 6 03:40:53 1999
+++ grub/shared_src/cmdline.c Sun Jun 6 21:51:10 1999
@@ -77,8 +77,11 @@
/* True when the debug mode is turned on, and false when it is turned off. */
int debug = 0;
+/* Color settings */
+int menucolor, reversecolor;
+
char *
skip_to(int after_equal, char *cmdline)
{
while (*cmdline && (*cmdline != (after_equal ? '=' : ' ')))
@@ -106,9 +109,9 @@
" Possible commands are: \"pause= ...\", \"uppermem= <kbytes>\", \"root= <device>\",
\"rootnoverify= <device>\", \"chainloader= <file>\", \"kernel= <file> ...\",
\"testload= <file>\", \"read= <addr>\", \"displaymem\", \"impsprobe\",
\"fstest\", \"debug\", \"module= <file> ...\", \"modulenounzip= <file> ...\",
- \"makeactive\", \"boot\", and
+ \"menucolor= <attrib>\", \"reversecolor= <attrib>\", \"makeactive\", \"boot\", and
\"install= <stage1_file> [d] <dest_dev> <file> <addr> [p] [<config_file>]\"\n";
static void
debug_fs_print_func(int sector)
@@ -631,9 +634,13 @@
debug = 1;
grub_printf (" Debug mode is turned on\n");
}
}
+ else if (substring ("menucolor", cur_heap) < 0)
+ safe_parse_maxint (&cur_cmdline, &menucolor);
+ else if (substring ("reversecolor", cur_heap) < 0)
+ safe_parse_maxint (&cur_cmdline, &reversecolor);
else if (*cur_heap && *cur_heap != ' ')
errnum = ERR_UNRECOGNIZED;
-
+
goto restart;
}
diff -u4 -r --new-file --exclude-from=diffexclude cvsgrub/shared_src/shared.h
grub/shared_src/shared.h
--- cvsgrub/shared_src/shared.h Sun Jun 6 03:40:54 1999
+++ grub/shared_src/shared.h Sun Jun 6 21:26:26 1999
@@ -311,8 +311,10 @@
extern void (*debug_fs) (int);
extern void (*debug_fs_func) (int);
/* The flag for debug mode. */
extern int debug;
+/* Color settings */
+extern int menucolor, reversecolor;
#endif /* STAGE1_5 */
extern unsigned long current_drive;
extern unsigned long current_partition;
@@ -423,8 +425,13 @@
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 -u4 -r --new-file --exclude-from=diffexclude cvsgrub/shared_src/stage2.c
grub/shared_src/stage2.c
--- cvsgrub/shared_src/stage2.c Tue Jun 1 16:59:50 1999
+++ grub/shared_src/stage2.c Sun Jun 6 21:47:26 1999
@@ -86,10 +86,18 @@
static void
print_border(int y, int size)
{
- int i;
+ int i, j;
+ /* Color the menu. The menu is 75 * 14 characters */
+ for (i = 0; i < 14; i++)
+ for (j = 0; j < 75; j++)
+ {
+ gotoxy(j + 1, i + y);
+ set_attrib(menucolor);
+ }
+
gotoxy(1, y);
putchar(DISP_UL);
for (i = 0; i < 73; i++)
@@ -151,8 +159,11 @@
first_entry++; entryno--;
}
init_page();
+#ifndef GRUB_UTIL
+ nocursor();
+#endif
print_border(3, 12);
printf("\n
@@ -178,9 +189,9 @@
print_entries(3, 12, first_entry, menu_entries);
/* invert initial line */
- set_line (4 + entryno, A_REVERSE);
+ set_line (4 + entryno, reversecolor);
/* XX using RT clock now, need to initialize value */
while ((time1 = getrtsecs()) == 0xFF);
@@ -221,33 +232,33 @@
if ((c == KEY_UP) || (ASCII_CHAR(c) == 16))
{
if (entryno > 0)
{
- set_line (4 + entryno, A_NORMAL);
+ set_line (4 + entryno, menucolor);
entryno --;
- set_line (4 + entryno, A_REVERSE);
+ set_line (4 + entryno, reversecolor);
}
else if (first_entry > 0)
{
first_entry --;
print_entries(3, 12, first_entry, menu_entries);
- set_line (4, A_REVERSE);
+ set_line (4, reversecolor);
}
}
if (((c == KEY_DOWN) || (ASCII_CHAR(c) == 14))
&& (first_entry+entryno+1) < num_entries)
{
if (entryno < 11)
{
- set_line (4 + entryno, A_NORMAL);
+ set_line (4 + entryno, menucolor);
entryno ++;
- set_line (4 + entryno, A_REVERSE);
+ set_line (4 + entryno, reversecolor);
}
else if (num_entries > 12+first_entry)
{
first_entry ++;
print_entries (3, 12, first_entry, menu_entries);
- set_line (15, A_REVERSE);
+ set_line (15, reversecolor);
}
}
c = ASCII_CHAR(c);
@@ -260,9 +271,9 @@
else
{
if ((c == 'd') || (c == 'o') || (c == 'O'))
{
- set_line (4 + entryno, A_NORMAL);
+ set_line (4 + entryno, menucolor);
/* insert after is almost exactly like insert before */
if (c == 'o')
{
entryno++;
@@ -517,9 +528,10 @@
char *config_entries, *menu_entries;
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;
+ menucolor=A_NORMAL; reversecolor=A_REVERSE;
config_entries = (char *)(mbi.mmap_addr + mbi.mmap_length);
menu_entries = (char *)(BUFFERADDR + (32 * 1024));
password = NULL; fallback = -1; grub_timeout = -1;
@@ -567,8 +579,12 @@
if (substring("fallback", cmdline) < 1)
safe_parse_maxint(&ptr, &fallback);
if (substring("default", cmdline) < 1)
safe_parse_maxint(&ptr, &default_entry);
+ if (substring("menucolor", cmdline) < 1)
+ safe_parse_maxint(&ptr, &menucolor);
+ if (substring("reversecolor", cmdline) < 1)
+ safe_parse_maxint(&ptr, &reversecolor);
if (substring("password", cmdline) < 1)
{
password = config_entries;
while ((*(config_entries++) = *(ptr++)) != 0);
/////
o o
-... Peter Astrand <[EMAIL PROTECTED]>