A number of terminal emulators (xterm with TERM=xterm-256color and st,
off the top of my head), interpret the A_BLINK attribute by actually
blinking, not setting the background color to the bright version. A
quick way to test this is
:color indicator black brightblack
which on some terms (urxvt) will cause black-on-gray text, and on
others (xterm) will cause an unreadable blinking line.
This patch changes that behavior by avoiding A_BLINK and directly
using the bright versions of colors if they are available. I've tested
it on urxvt, xterm (with TERM=xterm-256color), and st, and it behaves
as I expect. On xterm (with TERM=xterm), blinking still persists, but
it always did that anyway, so at least this patch doesn't seem to
break that case.
Please let me know if I have erred with style or submission.
--
S. Gilles
# HG changeset patch
# User S. Gilles <[email protected]>
# Date 1451569185 18000
# Thu Dec 31 08:39:45 2015 -0500
# Node ID bc242e89469b7443bc6126589dbdb2060f419844
# Parent 9480a363a68a7472d61c8e27a29fd2312cac8721
Prefer bright versions (8-15) of colors for brightXXX backgrounds.
When a bright color is specified as a background, try to use the
bright version of that color, falling back to the A_BLINK method only
on terms which do not support enough colors.
diff -r 9480a363a68a -r bc242e89469b color.c
--- a/color.c Thu Dec 17 12:25:00 2015 -0800
+++ b/color.c Thu Dec 31 08:39:45 2015 -0500
@@ -306,13 +306,14 @@
#ifdef HAVE_COLOR
static int
-parse_color_name (const char *s, int *col, int *attr, int brite, BUFFER *err)
+parse_color_name (const char *s, int *col, int *attr, int is_fg, BUFFER *err)
{
char *eptr;
+ int is_bright = 0;
if (ascii_strncasecmp (s, "bright", 6) == 0)
{
- *attr |= brite;
+ is_bright = 1;
s += 6;
}
@@ -334,6 +335,24 @@
return (-1);
}
+ if (is_bright)
+ {
+ if (is_fg)
+ {
+ *attr |= A_BOLD;
+ }
+ else if (COLORS < 16)
+ {
+ /* A_BLINK turns the background color brite on some terms */
+ *attr |= A_BLINK;
+ }
+ else
+ {
+ /* Advance the color by 8 to get the bright version */
+ *col += 8;
+ }
+ }
+
return 0;
}
@@ -615,7 +634,7 @@
mutt_extract_token (buf, s, 0);
- if (parse_color_name (buf->data, fg, attr, A_BOLD, err) != 0)
+ if (parse_color_name (buf->data, fg, attr, 1, err) != 0)
return (-1);
if (! MoreArgs (s))
@@ -626,7 +645,7 @@
mutt_extract_token (buf, s, 0);
- if (parse_color_name (buf->data, bg, attr, A_BLINK, err) != 0)
+ if (parse_color_name (buf->data, bg, attr, 0, err) != 0)
return (-1);
return 0;