aboutsummaryrefslogtreecommitdiff
path: root/config.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2021-05-08 11:54:14 +0000
committerDaniel Eklöf <daniel@ekloef.se>2021-05-08 11:54:14 +0000
commit31f747906536fbdbdaf4b4c7bacabee8c9e59726 (patch)
tree635bf4e7e5e7655b32dc7162d2515bde3166d258 /config.c
parentMerge branch 'bell-enhancement' (diff)
parentconfigure full color palette in foot.ini (diff)
Merge branch 'color-table-config'
Closes #489
Diffstat (limited to 'config.c')
-rw-r--r--config.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/config.c b/config.c
index bf6e125a..8dcdd51e 100644
--- a/config.c
+++ b/config.c
@@ -902,7 +902,20 @@ parse_section_colors(const char *key, const char *value, struct config *conf,
{
uint32_t *color = NULL;
- if (strcmp(key, "foreground") == 0) color = &conf->colors.fg;
+ if (isdigit(key[0])) {
+ unsigned long index;
+ if (!str_to_ulong(key, 0, &index)) {
+ LOG_AND_NOTIFY_ERR("%s:%d: [colors]: invalid numeric key", path, lineno);
+ return false;
+ }
+ if (index >= ALEN(conf->colors.table)) {
+ LOG_AND_NOTIFY_ERR("%s:%d: [colors]: numeric key out of range", path, lineno);
+ return false;
+ }
+ color = &conf->colors.table[index];
+ }
+
+ else if (strcmp(key, "foreground") == 0) color = &conf->colors.fg;
else if (strcmp(key, "background") == 0) color = &conf->colors.bg;
else if (strcmp(key, "regular0") == 0) color = &conf->colors.table[0];
else if (strcmp(key, "regular1") == 0) color = &conf->colors.table[1];