]> granicus.if.org Git - neomutt/commitdiff
Added support for the "light" color prefix (in addition to "bright")
authorVincent Lefevre <vincent@vinc17.net>
Sat, 29 Dec 2018 18:37:57 +0000 (19:37 +0100)
committerRichard Russon <rich@flatcap.org>
Mon, 7 Jan 2019 15:09:41 +0000 (15:09 +0000)
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 <rich@flatcap.org>
color.c
doc/manual.xml.head

diff --git a/color.c b/color.c
index 03fb2f96477ebd6948b60266f7c50e32aad0f961..b9b7382bc835430876fd96c7aacce9a336e5ef61 100644 (file)
--- 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;
+        }
+      }
     }
   }
 
index 9a6fae002f109e1ec8b19336d180940a289667c4..be7e1a0c5632565c4a162bf8281f846db6c5ae74 100644 (file)
@@ -4739,11 +4739,15 @@ folder-hook work "set sort=threads"
         </listitem>
       </itemizedlist>
       <para>
-        <emphasis>foreground</emphasis> can optionally be prefixed with the
-        keyword <literal>bright</literal> to make the foreground color
-        boldfaced (e.g., <literal>brightred</literal>).
+        The color name can optionally be prefixed with the keyword
+        <literal>bright</literal> or <literal>light</literal> to make the color
+        boldfaced or light (e.g., <literal>brightred</literal>).
         <literal>alert</literal> to make a blinking/alert color (e.g.,
-        <literal>alertred</literal>).
+        <literal>alertred</literal>).  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&nbsp;colors, as specified by the
+        <literal>$TERM</literal> environment variable.
       </para>
       <para>
         If your terminal supports it, the special keyword