aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOmar Polo <op@omarpolo.com>2021-06-22 19:43:26 +0200
committerOmar Polo <op@omarpolo.com>2021-06-22 19:43:26 +0200
commit27766d481f3a15b6ad16822034ca247c99c3e456 (patch)
tree3be2fb7b1c3724a71b5ea51d43a3cb8ca7fe3b19
parent33d904b669e543d144ac195a28f32de6b6785117 (diff)
downloadtelescope-27766d481f3a15b6ad16822034ca247c99c3e456.tar.gz
telescope-27766d481f3a15b6ad16822034ca247c99c3e456.tar.bz2
support 256 colors!
Allow `colorN' and `colourN' (where 0 <= N < 256) as color specifier.
-rw-r--r--ChangeLog2
-rw-r--r--parse.y18
2 files changed, 20 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index efb9ffd..3c547ec 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
2021-06-22 Omar Polo <op@omarpolo.com>
+ * parse.y (colorname): support 256 colors
+
* defaults.c (config_setcolor): allow changing the colors/attributes of the tabline
* parse.y (attrname): allow changing the attributes
diff --git a/parse.y b/parse.y
index 8f755a3..7765898 100644
--- a/parse.y
+++ b/parse.y
@@ -334,12 +334,30 @@ colorname(const char *name)
{ "white", COLOR_WHITE },
{ NULL, 0 },
};
+ const char *errstr;
+ int n;
+
+ if (has_prefix(name, "colo")) {
+ /* people are strange */
+ if (has_prefix(name, "color"))
+ name += 5;
+ else if (has_prefix(name, "colour"))
+ name += 6;
+ else
+ goto err;
+
+ n = strtonum(name, 0, 256, &errstr);
+ if (errstr != NULL)
+ yyerror("color number is %s: %s", errstr, name);
+ return n;
+ }
for (i = colors; i->name != NULL; ++i) {
if (!strcmp(i->name, name))
return i->val;
}
+err:
yyerror("unknown color name \"%s\"", name);
return -1;
}