diff --git a/CHANGELOG.md b/CHANGELOG.md index 33e64afd..e074583b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,6 +41,8 @@ * Dedicated bell section in config, supporting multiple actions and a new `command` action to run an arbitrary command. (https://codeberg.org/dnkl/foot/pulls/483) +* Support for setting the full 256 color palette in foot.ini + (https://codeberg.org/dnkl/foot/issues/489) ### Changed 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]; diff --git a/doc/foot.ini.5.scd b/doc/foot.ini.5.scd index 1030c841..abe90fc7 100644 --- a/doc/foot.ini.5.scd +++ b/doc/foot.ini.5.scd @@ -375,9 +375,9 @@ applications can change these at runtime. # SECTION: colors -This section controls the 16 ANSI colors and the default foreground -and background colors. Note that applications can change these at -runtime. +This section controls the 16 ANSI colors, the default foreground +and background colors, and the extended 256 color palette. Note that +applications can change these at runtime. The colors are in RRGGBB format. That is, they do *not* have an alpha component. You can configure the background transparency with the @@ -401,6 +401,12 @@ _alpha_ option. _bfebbf_, _f0dfaf_, _8cd0d3_, _fcace3_, _b3ffff_ and _ffffff_ (a variant of the _zenburn_ theme). +*0* *..* *255* + Arbitrary colors in the 256-color palette. Default: for *0* *..* + *15*, see regular and bright defaults above; see + https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit for an + explanation of the remainder. + *alpha* Background translucency. A value in the range 0.0-1.0, where 0.0 means completely transparent, and 1.0 is opaque. Default: _1.0_. diff --git a/foot.ini b/foot.ini index 6f0948a2..9e5c4e79 100644 --- a/foot.ini +++ b/foot.ini @@ -74,6 +74,9 @@ # bright5=fcace3 # bright magenta # bright6=b3ffff # bright cyan # bright7=ffffff # bright white +# 16 = <256-color palette #16> +# ... +# 255 = <256-color palette #255> # selection-foreground= # selection-background= # jump-labels=