commit 8804b6dcd4ac49ad526914418c4db0a59b8e4ba9
parent 86b83888891213d473ea077e2b50bdeba9171103
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Tue, 3 Oct 2023 15:41:00 +0200
tweaks: adjust a comment for the changed handling of gray #rgb codes
Diffstat:
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/rcfile.c b/src/rcfile.c
@@ -991,10 +991,11 @@ void parse_includes(char *ptr)
}
/* Return the index of the color that is closest to the given RGB levels,
- * assuming that the terminal uses the 6x6x6 color cube of xterm-256color. */
+ * assuming that the terminal uses the 6x6x6 color cube of xterm-256color.
+ * When red == green == blue, return an index in the xterm gray scale. */
short closest_index_color(short red, short green, short blue)
{
- /* Translation table, from 16 intended levels to 6 available levels. */
+ /* Translation table, from 16 intended color levels to 6 available levels. */
static const short level[] = { 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5 };
/* Translation table, from 14 intended gray levels to 24 available levels. */
@@ -1002,7 +1003,7 @@ short closest_index_color(short red, short green, short blue)
if (COLORS != 256)
return THE_DEFAULT;
- else if (red == green && red == blue && red > 0 && red < 0xF)
+ else if (red == green && green == blue && 0 < red && red < 0xF)
return 232 + gray[red - 1];
else
return (36 * level[red] + 6 * level[green] + level[blue] + 16);