From: Andy Spencer Date: Tue, 24 Nov 2009 15:51:44 +0000 (+0000) Subject: colors: Allow using 256 colors X-Git-Tag: release-0.16~16 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=9b174ec4b7f3ecfa0cf43919ea199df09af971da;hp=98c6201771be9b717d100440a198c200352f7ab9;p=ncmpc.git 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. --- 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; }