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.master
parent
96a5aa9e90
commit
f6e7b7fbc5
15
src/rcfile.c
15
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;
|
||||
|
|
Loading…
Reference in New Issue