From dacd8747e764c5a263be13fc1ebde5658093a110 Mon Sep 17 00:00:00 2001 From: Rayford Shireman <123055883+rayfordshire@users.noreply.github.com> Date: Sat, 4 Mar 2023 13:46:01 +0000 Subject: [PATCH] Colors: Workaround for colors #000000 to #000007 The colours #000000 to #000007 correspond to the numbers 0 to 7. Even when calling the *_extended_* functions of ncurses those colours correspond to the eight default terminal colours and not to some dark blacks. Interestingly, colour numbers 8 to 15 (the default bright colours of the terminal), do not show this behaviour. As a workaround we round these eight RGB colours up to #000008 (the darkest black we can achieve) and hope nobody notices. --- color/command.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/color/command.c b/color/command.c index cb0c763ab70..5b571aab4a4 100644 --- a/color/command.c +++ b/color/command.c @@ -287,6 +287,11 @@ static enum CommandResult parse_color_name(const char *s, uint32_t *col, int *at /* If we are running in direct color mode, we must convert the xterm * color numbers 0-255 to an RGB value. */ *col = color_xterm256_to_24bit(*col); + /* FIXME: The color values 0 to 7 (both inclusive) are still occupied by + * the default terminal colours. As a workaround we round them up to + * #000008 which is the blackest black we can produce. */ + if (*col < 8) + *col = 8; } #endif color_debug(LL_DEBUG5, "colorNNN %d\n", *col); @@ -314,6 +319,12 @@ static enum CommandResult parse_color_name(const char *s, uint32_t *col, int *at buf_printf(err, _("%s: color not supported by term"), s); return MUTT_CMD_ERROR; } + /* FIXME: The color values 0 to 7 (both inclusive) are still occupied by + * the default terminal colours. As a workaround we round them up to + * #000008 which is the blackest black we can produce. */ + if (*col < 8) + *col = 8; + color_debug(LL_DEBUG5, "#RRGGBB: %d\n", *col); return MUTT_CMD_SUCCESS; }