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

4
osc.c
View file

@ -1480,12 +1480,10 @@ osc_dispatch(struct terminal *term)
case 17:
term->colors.selection_bg = color;
term->colors.use_custom_selection = true;
break;
case 19:
term->colors.selection_fg = color;
term->colors.use_custom_selection = true;
break;
}
@ -1589,13 +1587,11 @@ osc_dispatch(struct terminal *term)
case 117:
LOG_DBG("resetting selection background color");
term->colors.selection_bg = term->conf->colors.selection_bg;
term->colors.use_custom_selection = term->conf->colors.use_custom.selection;
break;
case 119:
LOG_DBG("resetting selection foreground color");
term->colors.selection_fg = term->conf->colors.selection_fg;
term->colors.use_custom_selection = term->conf->colors.use_custom.selection;
break;
case 133: