On Mon, Dec 17, 2018 at 03:41:36AM +0100, Vincent Lefevre wrote:
If one chooses to support "bold" for terminals with >= 16 colors,
I think that instead of "boldbright", the "bold" prefix would be
sufficient, because when the bold attribute is set, adding 8 or
not to the color number does not seem to produce different results
(I've tested various terminals). In short, one would use:

#colors      < 16     >= 16
bright      A_BOLD     + 8
bold        A_BOLD    A_BOLD

That sounds reasonable. I'm attaching a possible patch - does that look like what you are thinking?

Since "bright" was mis-named, I don't see a way to change things without affecting older users, but it's easy enough to add a "bold" prefix too.

Another thing, I've just noticed that one should not use the
"bright" prefix for "colorx" with x >= 8. So, the patch is a
bit incorrect (but so is the current code for the background
colors). And "brightdefault" should be incorrect too.

Agreed, but I don't think it's a big enough deal to worry about, since
it's been that way forever. :)

--
Kevin J. McCarthy
GPG Fingerprint: 8975 A9B3 3AA3 7910 385C  5308 ADEF 7684 8031 6BDA
From a59243409f16a13d4163eaf7b1c3fa51e5151003 Mon Sep 17 00:00:00 2001
From: Kevin McCarthy <ke...@8t8.us>
Date: Mon, 17 Dec 2018 12:19:47 -0800
Subject: [PATCH] Add bold prefix to colors.

---
 color.c | 36 ++++++++++++++++++++++++++----------
 1 file changed, 26 insertions(+), 10 deletions(-)

diff --git a/color.c b/color.c
index af979dfc..576a2295 100644
--- a/color.c
+++ b/color.c
@@ -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_bold = 0;
 
   if (ascii_strncasecmp (s, "bright", 6) == 0)
   {
     is_bright = 1;
     s += 6;
   }
+  else if (ascii_strncasecmp (s, "bold", 4) == 0)
+  {
+    is_bold = 1;
+    s += 4;
+  }
 
   /* allow aliases for xterm color resources */
   if (ascii_strncasecmp (s, "color", 5) == 0)
@@ -357,21 +362,32 @@ parse_color_name (const char *s, int *col, int *attr, int is_fg, BUFFER *err)
     return (-1);
   }
 
-  if (is_bright)
+  if (is_bright || is_bold)
   {
     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_bright)
+      {
+        /* Advance the color by 8 to get the bright version */
+        *col += 8;
+      }
+      else
+      {
+        *attr |= A_BOLD;
+      }
     }
     else
     {
-      /* Advance the color by 8 to get the bright version */
-      *col += 8;
+      if (COLORS >= 16)
+      {
+        /* Advance the color by 8 to get the bright version */
+        *col += 8;
+      }
+      else
+      {
+        /* A_BLINK turns the background color brite on some terms */
+        *attr |= A_BLINK;
+      }
     }
   }
 
-- 
2.19.2

Attachment: signature.asc
Description: PGP signature

Reply via email to