render: refactor to allow setting only selection bg or fg

Before this, we only applied custom selection colors, if *both* the
selection bg and fg had been set.

Since the options are already split up into two separate options, and
since it makes sense to at least be able to keep the foreground colors
unchanged (i.e. only setting the selection background), let's allow
only having one of the selection colors set.

Closes #1846
This commit is contained in:
Daniel Eklöf 2025-05-05 12:43:02 +02:00
parent c037836bbd
commit 073b637d45
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
8 changed files with 68 additions and 60 deletions

View file

@ -1312,7 +1312,6 @@ term_init(const struct config *conf, struct fdm *fdm, struct reaper *reaper,
.cursor_bg = (theme->use_custom.cursor ? 1u << 31 : 0) | theme->cursor.cursor,
.selection_fg = theme->selection_fg,
.selection_bg = theme->selection_bg,
.use_custom_selection = theme->use_custom.selection,
.active_theme = conf->initial_color_theme,
},
.color_stack = {
@ -4714,6 +4713,5 @@ term_theme_apply(struct terminal *term, const struct color_theme *theme)
term->colors.cursor_bg = (theme->use_custom.cursor ? 1u << 31 : 0) | theme->cursor.cursor;
term->colors.selection_fg = theme->selection_fg;
term->colors.selection_bg = theme->selection_bg;
term->colors.use_custom_selection = theme->use_custom.selection;
memcpy(term->colors.table, theme->table, sizeof(term->colors.table));
}