From: H. Peter Anvin Date: Tue, 5 Jun 2007 20:52:03 +0000 (-0700) Subject: com32: change the message color scheme; background 0 is always transparent X-Git-Tag: syslinux-3.50-pre19~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bc97f0c0b51bd1fdc49f756200dd2805f7aac08d;p=profile%2Fivi%2Fsyslinux.git 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. --- diff --git a/README.menu b/README.menu index 437105b..71d32e5 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 9bf25b5..e6fcbcd 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 a984ba4..6f890f2 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 0e84827..107a1d0 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 a4eb143..a2f9cfd 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;