nano-devel
[Top][All Lists]
Advanced

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

[PATCH] rcfile: introduce nine new named colors, from "pink" to "latte"


From: Benno Schulenberg
Subject: [PATCH] rcfile: introduce nine new named colors, from "pink" to "latte"
Date: Sun, 14 Jun 2020 16:49:31 +0200

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 characters apart.

This partially fulfills https://savannah.gnu.org/bugs/?56445.
---
 src/rcfile.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/src/rcfile.c b/src/rcfile.c
index 109e9a16..69925fbc 100644
--- a/src/rcfile.c
+++ b/src/rcfile.c
@@ -980,6 +980,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)
@@ -1015,6 +1019,15 @@ 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
+                                       return indices[index];
+                       }
 
        jot_error(N_("Color \"%s\" not understood"), colorname);
        return BAD_COLOR;
-- 
2.25.4




reply via email to

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