From 9b174ec4b7f3ecfa0cf43919ea199df09af971da Mon Sep 17 00:00:00 2001 From: Andy Spencer Date: Tue, 24 Nov 2009 15:51:44 +0000 Subject: [PATCH] colors: Allow using 256 colors Return the corresponding value when integers are passed to str2color. This allows high colors to be used with 256 color terminals. Bright colors can be used by adding 256 to integer. COLOR_BRIGHT_MASK changed to avoid conflicts with >127 colors. --- src/colors.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/colors.c b/src/colors.c index 1b3300d..75aef55 100644 --- a/src/colors.c +++ b/src/colors.c @@ -29,7 +29,7 @@ #include #include -#define COLOR_BRIGHT_MASK (1<<7) +#define COLOR_BRIGHT_MASK (1<<8) #define COLOR_BRIGHT_BLACK (COLOR_BLACK | COLOR_BRIGHT_MASK) #define COLOR_BRIGHT_RED (COLOR_RED | COLOR_BRIGHT_MASK) @@ -136,6 +136,8 @@ colors_update_pair(enum color id) short colors_str2color(const char *str) { + short color; + if (!strcasecmp(str, "black")) return COLOR_BLACK; else if (!strcasecmp(str, "red")) @@ -171,6 +173,12 @@ colors_str2color(const char *str) else if (!strcasecmp(str, "none")) return -1; + if (!strcmp(str, "0")) + return 0; + color = atoi(str); + if (color > 0) + return color; + fprintf(stderr,_("Warning: Unknown color - %s\n"), str); return -2; } -- 2.30.2