nano-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 4/4] rcfile: allow bolding also the first eight (non-intense) col


From: Benno Schulenberg
Subject: [PATCH 4/4] rcfile: allow bolding also the first eight (non-intense) colors
Date: Thu, 11 Jun 2020 20:02:52 +0200

When "bold" is specified without "lit", then replace the given color with
one from the 216-color palette (in case the terminal has that many colors)
that is closest to it in hue and intensity.  This makes ncurses emit the
relevant escape sequences to show the affected text in a bold typeface,
which it will not do for colors 0 to 7.

This fully fulfills https://savannah.gnu.org/bugs/?58503.
---
 src/rcfile.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/rcfile.c b/src/rcfile.c
index 725c4ecb..4a816bfd 100644
--- a/src/rcfile.c
+++ b/src/rcfile.c
@@ -1020,6 +1020,9 @@ short color_to_short(const char *colorname, bool *vivid, 
bool *thick)
        return BAD_COLOR;
 }
 
+/* Replacement colors from the palette to allow bolding the first eight. */
+short closest[COLOR_WHITE + 1] = { 16, 88, 28, 100, 18, 90, 30, 145 };
+
 /* Parse the color name (or pair of color names) in the given string.
  * Return FALSE when any color name is invalid; otherwise return TRUE. */
 bool parse_combination(char *combostr, short *fg, short *bg, int *attributes)
@@ -1057,7 +1060,9 @@ bool parse_combination(char *combostr, short *fg, short 
*bg, int *attributes)
                *fg = color_to_short(combostr, &vivid, &thick);
                if (*fg == BAD_COLOR)
                        return FALSE;
-               if (vivid && !thick && COLORS > 8)
+               if (!vivid && (*attributes & A_BOLD) && COLORS > 88)
+                       *fg = closest[*fg];
+               else if (vivid && !thick && COLORS > 8)
                        *fg += 8;
                else if (vivid)
                        *attributes |= A_BOLD;
-- 
2.25.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]