diff options
author | Vincent Lefevre <vincent@vinc17.net> | 2018-12-29 19:37:57 +0100 |
---|---|---|
committer | Vincent Lefevre <vincent@vinc17.net> | 2018-12-29 19:52:38 +0100 |
commit | 7af70af5d94467d7833abf919297f1f4a615ad33 (patch) | |
tree | aec364d0f45aeacf25a21a1aaccd7a4182e3ae66 /color.c | |
parent | 3f13b2575a1dfe28279de6057d50b10f603a7cce (diff) |
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).
Diffstat (limited to 'color.c')
-rw-r--r-- | color.c | 37 |
1 files changed, 27 insertions, 10 deletions
@@ -331,13 +331,18 @@ static int parse_color_name (const char *s, int *col, int *attr, int is_fg, BUFFER *err) { char *eptr; - int is_bright = 0; + int is_bright = 0, is_light = 0; if (ascii_strncasecmp (s, "bright", 6) == 0) { is_bright = 1; s += 6; } + else if (ascii_strncasecmp (s, "light", 5) == 0) + { + is_light = 1; + s += 5; + } /* allow aliases for xterm color resources */ if (ascii_strncasecmp (s, "color", 5) == 0) @@ -357,21 +362,33 @@ parse_color_name (const char *s, int *col, int *attr, int is_fg, BUFFER *err) return (-1); } - if (is_bright) + if (is_bright || is_light) { 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; + } + } } } |