config: add colors.dim-blend-towards=black|white

Before this patch, we always blended towards black when dimming
text. However, with light color themes, it usually looks better if we
dim towards white instead.

This option allows you to choose which color to blend towards.

The default is 'black' in '[colors]', and 'white' in '[colors2]'.

Closes #2187
This commit is contained in:
Daniel Eklöf 2025-10-10 11:10:38 +02:00
parent 371837ef7b
commit 7ed36c1033
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
7 changed files with 51 additions and 4 deletions

View file

@ -1519,7 +1519,7 @@ parse_color_theme(struct context *ctx, struct color_theme *theme)
return true;
}
else if (strcmp(key, "alpha-mode") == 0) {
else if (streq(key, "alpha-mode")) {
_Static_assert(sizeof(theme->alpha_mode) == sizeof(int),
"enum is not 32-bit");
@ -1529,6 +1529,16 @@ parse_color_theme(struct context *ctx, struct color_theme *theme)
(int *)&theme->alpha_mode);
}
else if (streq(key, "dim-blend-towards")) {
_Static_assert(sizeof(theme->dim_blend_towards) == sizeof(int),
"enum is not 32-bit");
return value_to_enum(
ctx,
(const char *[]){"black", "white", NULL},
(int *)&theme->dim_blend_towards);
}
else {
LOG_CONTEXTUAL_ERR("not valid option");
return false;
@ -3428,6 +3438,7 @@ config_load(struct config *conf, const char *conf_path,
.flash_alpha = 0x7fff,
.alpha = 0xffff,
.alpha_mode = ALPHA_MODE_DEFAULT,
.dim_blend_towards = DIM_BLEND_TOWARDS_BLACK,
.selection_fg = 0x80000000, /* Use default bg */
.selection_bg = 0x80000000, /* Use default fg */
.cursor = {
@ -3523,6 +3534,8 @@ config_load(struct config *conf, const char *conf_path,
memcpy(conf->colors.table, default_color_table, sizeof(default_color_table));
memcpy(conf->colors.sixel, default_sixel_colors, sizeof(default_sixel_colors));
memcpy(&conf->colors2, &conf->colors, sizeof(conf->colors));
conf->colors2.dim_blend_towards = DIM_BLEND_TOWARDS_WHITE;
parse_modifiers(XKB_MOD_NAME_SHIFT, 5, &conf->mouse.selection_override_modifiers);
tokenize_cmdline(