summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2007-06-05 13:52:03 -0700
committerH. Peter Anvin <hpa@zytor.com>2007-06-05 13:52:03 -0700
commitbc97f0c0b51bd1fdc49f756200dd2805f7aac08d (patch)
tree7766d25ad15dea906a532a81f198794c5887a483
parent350051f3fe38c27e2c32e12aacd7417e845fd428 (diff)
downloadsyslinux-bc97f0c0b51bd1fdc49f756200dd2805f7aac08d.tar.gz
com32: change the message color scheme; background 0 is always transparent
Change the default message color scheme, and allow the user to tweak the global parameters as well as individual entries.
-rw-r--r--README.menu14
-rw-r--r--com32/modules/menu.h9
-rw-r--r--com32/modules/menumain.c45
-rw-r--r--com32/modules/printmsg.c6
-rw-r--r--com32/modules/readconfig.c37
5 files changed, 96 insertions, 15 deletions
diff --git a/README.menu b/README.menu
index 437105bd..71d32e51 100644
--- a/README.menu
+++ b/README.menu
@@ -253,7 +253,19 @@ MENU COLOR element ansi foreground background shadow
menu color timeout_msg 37;40 #80ffffff #00000000 std
menu color timeout 1;37;40 #c0ffffff #00000000 std
menu color help 37;40 #c0ffffff #00000000 std
- menu color msg07 37;40 #c0ffffff #40000000 std
+ menu color msg07 37;40 #90ffffff #00000000 std
+
+
+MENU MSGCOLOR fg_filter bg_filter shadow
+
+ Sets *all* the msgXX colors to a color scheme derived from the
+ fg_filter and bg_filter values. Background color zero is
+ always treated as transparent. The default corresponds to:
+
+ menu msgcolor #90ffffff #80ffffff std
+
+ This directive should come before any directive that
+ customizes individual msgXX colors.
MENU WIDTH 80
diff --git a/com32/modules/menu.h b/com32/modules/menu.h
index 9bf25b55..e6fcbcd0 100644
--- a/com32/modules/menu.h
+++ b/com32/modules/menu.h
@@ -123,11 +123,14 @@ int menu_main(int argc, char *argv[]);
void console_prepare(void);
void console_cleanup(void);
-void set_msg_colors_global(unsigned int fg, unsigned int bg,
- enum color_table_shadow shadow);
-
extern const int message_base_color;
int mygetkey(clock_t timeout);
int show_message_file(const char *filename, const char *background);
+#define MSG_COLORS_DEF_FG 0x90ffffff
+#define MSG_COLORS_DEF_BG 0x80ffffff
+#define MSG_COLORS_DEF_SHADOW SHADOW_NORMAL
+void set_msg_colors_global(unsigned int fg, unsigned int bg,
+ enum color_table_shadow shadow);
+
#endif /* MENU_H */
diff --git a/com32/modules/menumain.c b/com32/modules/menumain.c
index a984ba4e..6f890f2b 100644
--- a/com32/modules/menumain.c
+++ b/com32/modules/menumain.c
@@ -117,22 +117,50 @@ void set_msg_colors_global(unsigned int fg, unsigned int bg,
{
struct color_table *cp = console_color_table+message_base_color;
unsigned int i;
+ unsigned int fga, bga;
unsigned int fgh, bgh;
+ unsigned int fg_idx, bg_idx;
+ unsigned int fg_rgb, bg_rgb;
static const unsigned int pc2rgb[8] =
{ 0x000000, 0x0000ff, 0x00ff00, 0x00ffff, 0xff0000, 0xff00ff, 0xffff00,
0xffffff };
- fg &= 0xff000000; /* Alpha only */
- bg &= 0xff000000; /* Alpha only */
+ /* Converting PC RGBI to sensible RGBA values is an "interesting"
+ proposition. This algorithm may need plenty of tweaking. */
+
+ fga = fg & 0xff000000;
+ fgh = ((fg >> 1) & 0xff000000) | 0x80000000;
- fgh = (0x80000000+(fg >> 1)) & 0xff000000;
- bgh = (0x80000000+(bg >> 1)) & 0xff000000;
+ bga = bg & 0xff000000;
+ bgh = ((bg >> 1) & 0xff000000) | 0x80000000;
for (i = 0; i < 256; i++) {
- cp->argb_fg = pc2rgb[i & 7] | ((i & 0x08) ? fgh : fg);
- cp->argb_bg = pc2rgb[(i >> 4) & 7] | ((i & 0x80) ? bgh : bg);
- cp->shadow = shadow;
+ fg_idx = i & 15;
+ bg_idx = i >> 4;
+
+ fg_rgb = pc2rgb[fg_idx & 7] & fg;
+ bg_rgb = pc2rgb[bg_idx & 7] & bg;
+
+ if (fg_idx & 8) {
+ /* High intensity foreground */
+ fg_rgb |= fgh;
+ } else {
+ fg_rgb |= fga;
+ }
+
+ if (bg_idx == 0) {
+ /* Default black background, assume transparent */
+ bg_rgb = 0;
+ } else if (bg_idx & 8) {
+ bg_rgb |= bgh;
+ } else {
+ bg_rgb |= bga;
+ }
+
+ cp->argb_fg = fg_rgb;
+ cp->argb_bg = bg_rgb;
+ cp->shadow = shadow;
cp++;
}
}
@@ -176,7 +204,8 @@ install_default_color_table(void)
console_color_table = color_table;
console_color_table_size = NCOLORS+256;
- set_msg_colors_global(0xc0000000, 0x40000000, SHADOW_NORMAL);
+ set_msg_colors_global(MSG_COLORS_DEF_FG, MSG_COLORS_DEF_BG,
+ MSG_COLORS_DEF_SHADOW);
}
static char *
diff --git a/com32/modules/printmsg.c b/com32/modules/printmsg.c
index 0e848270..107a1d0e 100644
--- a/com32/modules/printmsg.c
+++ b/com32/modules/printmsg.c
@@ -19,13 +19,13 @@
int (*draw_background)(const char *filename);
-static int hexval(char c)
+static int hexval(int c)
{
- if (c >= '0' || c <= '9')
+ if (c >= '0' && c <= '9')
return c-'0';
c |= 0x20;
- if (c >= 'a' || c <= 'f')
+ if (c >= 'a' && c <= 'f')
return c-'a'+10;
return 0;
diff --git a/com32/modules/readconfig.c b/com32/modules/readconfig.c
index a4eb1435..a2f9cfd8 100644
--- a/com32/modules/readconfig.c
+++ b/com32/modules/readconfig.c
@@ -558,6 +558,43 @@ static void parse_config_file(FILE *f)
}
cptr++;
}
+ } else if ((ep = looking_at(p, "msgcolor")) ||
+ (ep = looking_at(p, "msgcolour"))) {
+ unsigned int fg_mask = MSG_COLORS_DEF_FG;
+ unsigned int bg_mask = MSG_COLORS_DEF_BG;
+ enum color_table_shadow shadow = MSG_COLORS_DEF_SHADOW;
+
+ p = skipspace(ep);
+ if (*p) {
+ if (!looking_at(p, "*"))
+ fg_mask = parse_argb(&p);
+
+ p = skipspace(p);
+ if (*p) {
+ if (!looking_at(p, "*"))
+ bg_mask = parse_argb(&p);
+
+ p = skipspace(p);
+ switch (*p | 0x20) {
+ case 'n':
+ shadow = SHADOW_NONE;
+ break;
+ case 's':
+ shadow = SHADOW_NORMAL;
+ break;
+ case 'a':
+ shadow = SHADOW_ALL;
+ break;
+ case 'r':
+ shadow = SHADOW_REVERSE;
+ break;
+ default:
+ /* go with default */
+ break;
+ }
+ }
+ }
+ set_msg_colors_global(fg_mask, bg_mask, shadow);
} else {
/* Unknown, check for layout parameters */
struct menu_parameter *pp;