osc: implement OSC 17+19: change selection background/foreground colors

And of course, we also implement the corresponding reset sequences,
OSC 117+119.
This commit is contained in:
Daniel Eklöf 2021-04-07 08:09:40 +02:00
parent deb08ddba0
commit 55b343f690
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
6 changed files with 67 additions and 13 deletions

34
osc.c
View file

@ -679,8 +679,10 @@ osc_dispatch(struct terminal *term)
break;
case 10:
case 11: {
/* Set default foreground/background color */
case 11:
case 17:
case 19: {
/* Set default foreground/background/highlight-bg/highlight-fg color */
/* Client queried for current value */
if (strlen(string) == 1 && string[0] == '?') {
@ -714,7 +716,11 @@ osc_dispatch(struct terminal *term)
}
LOG_DBG("change color definition for %s to %06x",
param == 10 ? "foreground" : "background", color);
param == 10 ? "foreground" :
param == 11 ? "background" :
param == 17 ? "selection background" :
"selection foreground",
color);
switch (param) {
case 10:
@ -726,6 +732,16 @@ osc_dispatch(struct terminal *term)
if (have_alpha)
term->colors.alpha = alpha;
break;
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;
}
term_damage_view(term);
@ -836,6 +852,18 @@ osc_dispatch(struct terminal *term)
term_damage_cursor(term);
break;
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 555:
osc_flash(term);
break;