From: Vincent Lefevre Date: Sat, 29 Dec 2018 18:37:57 +0000 (+0100) Subject: Added support for the "light" color prefix (in addition to "bright") X-Git-Tag: 2019-10-25~396^2~10 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=277fce4d183997484378c3bebe192f24d65cd68c;p=neomutt Added support for the "light" color prefix (in addition to "bright") At the same time, restrict the advance by 8 to colors in the range 0-7 and no longer use the blink attribute to emulate light background colors in some terminals (e.g. linux console and rxvt), as this is really blink in other terminals (e.g. xterm); light background colors can still be obtained by choosing a proper $TERM value (tested with linux console, using TERM=linux-16color, and rxvt). Co-authored-by: Richard Russon --- diff --git a/color.c b/color.c index 03fb2f964..b9b7382bc 100644 --- a/color.c +++ b/color.c @@ -451,26 +451,32 @@ void mutt_free_color(int fg, int bg) static int parse_color_name(const char *s, int *col, int *attr, bool is_fg, struct Buffer *err) { char *eptr = NULL; - int is_alert = 0, is_bright = 0; + bool is_alert = false, is_bright = false, is_light = false; + int clen; - if (mutt_str_startswith(s, "bright", CASE_IGNORE)) + if ((clen = mutt_str_startswith(s, "bright", CASE_IGNORE))) { - is_bright = 1; - s += 6; + is_bright = true; + s += clen; } - else if (mutt_str_startswith(s, "alert", CASE_IGNORE)) + else if ((clen = mutt_str_startswith(s, "alert", CASE_IGNORE))) { - is_alert = 1; - is_bright = 1; - s += 5; + is_alert = true; + is_bright = true; + s += clen; + } + else if ((clen = mutt_str_startswith(s, "light", CASE_IGNORE))) + { + is_light = true; + s += clen; } /* allow aliases for xterm color resources */ - if (mutt_str_startswith(s, "color", CASE_IGNORE)) + if ((clen = mutt_str_startswith(s, "color", CASE_IGNORE))) { - s += 5; + s += clen; *col = strtol(s, &eptr, 10); - if (!*s || *eptr || *col < 0 || (*col >= COLORS && !OptNoCurses && has_colors())) + if (!*s || *eptr || (*col < 0) || ((*col >= COLORS) && !OptNoCurses && has_colors())) { mutt_buffer_printf(err, _("%s: color not supported by term"), s); return -1; @@ -482,7 +488,7 @@ static int parse_color_name(const char *s, int *col, int *attr, bool is_fg, stru return -1; } - if (is_bright) + if (is_bright || is_light) { if (is_alert) { @@ -491,17 +497,29 @@ static int parse_color_name(const char *s, int *col, int *attr, bool is_fg, stru } else if (is_fg) { - *attr |= A_BOLD; - } - else if (COLORS < 16) - { - /* A_BLINK turns the background color brite on some terms */ - *attr |= A_BLINK; + if ((COLORS >= 16) && is_light) + { + if (*col < 8) + { + /* Advance the color 0-7 by 8 to get the light version */ + *col += 8; + } + } + else + { + *attr |= A_BOLD; + } } else { - /* Advance the color by 8 to get the bright version */ - *col += 8; + if (COLORS >= 16) + { + if (*col < 8) + { + /* Advance the color 0-7 by 8 to get the light version */ + *col += 8; + } + } } } diff --git a/doc/manual.xml.head b/doc/manual.xml.head index 9a6fae002..be7e1a0c5 100644 --- a/doc/manual.xml.head +++ b/doc/manual.xml.head @@ -4739,11 +4739,15 @@ folder-hook work "set sort=threads" - foreground can optionally be prefixed with the - keyword bright to make the foreground color - boldfaced (e.g., brightred). + The color name can optionally be prefixed with the keyword + bright or light to make the color + boldfaced or light (e.g., brightred). alert to make a blinking/alert color (e.g., - alertred). + alertred). The precise behavior depends on the + terminal and its configuration. In particular, the boldfaced/light + difference and such background colors may be available only for + terminals configured with at least 16 colors, as specified by the + $TERM environment variable. If your terminal supports it, the special keyword