commit f6e7b7fbc501dc5d9d54430983f9b8be1a16cc02
parent 96a5aa9e90cbd8906b498fda9dc414a920fc49f4
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Tue, 9 Jun 2020 17:05:42 +0200
rcfile: introduce nine new named colors, from "pink" to "latte"
Names give a rough idea of what the color will look like, whereas
numerical indexes would not do this at all.
Nine extra colors seems enough. If there were more, no one would be
able to say for sure which is which when two similar colors are used
several rows apart.
This partially fulfills https://savannah.gnu.org/bugs/?56445.
Diffstat:
1 file changed, 15 insertions(+), 0 deletions(-)
diff --git a/src/rcfile.c b/src/rcfile.c
@@ -982,6 +982,10 @@ void parse_includes(char *ptr)
free(expanded);
}
+const char hues[9][7] = { "pink", "purple", "mauve", "lagoon", "mint",
+ "lime", "peach", "orange", "latte" };
+short indices[9] = { 204, 164, 140, 38, 48, 148, 215, 208, 137 };
+
/* Return the short value corresponding to the given color name, and set
* vivid to TRUE for a lighter color, and thick for a heavier typeface. */
short color_to_short(const char *colorname, bool *vivid, bool *thick)
@@ -1017,6 +1021,17 @@ short color_to_short(const char *colorname, bool *vivid, bool *thick)
return COLOR_BLACK;
else if (strcmp(colorname, "normal") == 0)
return USE_THE_DEFAULT;
+ else
+ for (int index = 0; index < 9; index++)
+ if (strcmp(colorname, hues[index]) == 0) {
+ if (*vivid) {
+ jot_error(N_("Color '%s' takes no prefix"), colorname);
+ return BAD_COLOR;
+ } else if (COLORS < 255)
+ return USE_THE_DEFAULT;
+ else
+ return indices[index];
+ }
jot_error(N_("Color \"%s\" not understood"), colorname);
return BAD_COLOR;