diff --git a/config.c b/config.c index 77dc3a73..8c7c6331 100644 --- a/config.c +++ b/config.c @@ -1388,6 +1388,15 @@ parse_color_theme(struct context *ctx, struct color_theme *theme) return true; } + else if (key_len == 11 && str_has_prefix(key, "background") && last_digit < 8) + { + if (!value_to_color(ctx, &theme->background[last_digit], false)) + return false; + + theme->use_custom.background |= 1 << last_digit; + return true; + } + else if (str_has_prefix(key, "sixel") && ((key_len == 6 && last_digit < 10) || (key_len == 7 && key[5] == '1' && last_digit < 6))) diff --git a/config.h b/config.h index 315f7e24..cbe23fcd 100644 --- a/config.h +++ b/config.h @@ -143,6 +143,7 @@ struct color_theme { uint32_t url; uint32_t dim[8]; + uint32_t background[8]; uint32_t sixel[16]; enum { @@ -186,6 +187,7 @@ struct color_theme { bool search_box_no_match:1; bool search_box_match:1; uint8_t dim; + uint8_t background; } use_custom; }; diff --git a/doc/foot.ini.5.scd b/doc/foot.ini.5.scd index 74b3f35b..963cde99 100644 --- a/doc/foot.ini.5.scd +++ b/doc/foot.ini.5.scd @@ -1017,6 +1017,14 @@ dark theme (since the default theme is dark). _e9e836_, _5dc5f8_, _feabf2_, _24dfc4_, _ffffff_ (starlight theme, V4). +*background0*, *background1* *..* *background7* + Custom colors to use for background colors. By default the eight + foreground colors are used. + + Note that applications can change the *regularN* colors at runtime + which affects the background colors when *backgroundN* is not + defined. + *dim0*, *dim1* *..* *dim7* Custom colors to use with dimmed colors. Dimmed colors do not have an entry in the color palette. Applications emit them by combining diff --git a/foot.ini b/foot.ini index 73fdb7ab..a2b657b5 100644 --- a/foot.ini +++ b/foot.ini @@ -134,6 +134,16 @@ # ... # dim7= +## custom background colors (see foot.ini(5) man page) +# background0= # black +# background1= # red +# background2= # green +# background3= # yellow +# background4= # blue +# background5= # magenta +# background6= # cyan +# background7= # white + ## The remaining 256-color palette # 16 = <256-color palette #16> # ... diff --git a/render.c b/render.c index 1c24bafa..67817b0f 100644 --- a/render.c +++ b/render.c @@ -725,7 +725,10 @@ render_cell(struct terminal *term, pixman_image_t *pix, case COLOR_BASE16: case COLOR_BASE256: xassert(cell->attrs.bg < ALEN(term->colors.table)); - _bg = term->colors.table[cell->attrs.bg]; + if (cell->attrs.bg < 8 && term->conf->colors.use_custom.background & (1 << cell->attrs.bg)) + _bg = term->conf->colors.background[cell->attrs.bg]; + else + _bg = term->colors.table[cell->attrs.bg]; break; case COLOR_DEFAULT: