mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-05 04:06:08 -05:00
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:
parent
deb08ddba0
commit
55b343f690
6 changed files with 67 additions and 13 deletions
|
|
@ -30,6 +30,8 @@
|
|||
|
||||
* URxvt OSC-11 extension to set background alpha
|
||||
(https://codeberg.org/dnkl/foot/issues/436).
|
||||
* OSC 17+19 - change selection background/foreground color.
|
||||
* OSC 117+119 - reset selection background/foreground color.
|
||||
|
||||
|
||||
### Changed
|
||||
|
|
|
|||
|
|
@ -564,7 +564,7 @@ All _OSC_ sequences begin with *\\E]*, sometimes abbreviated _OSC_.
|
|||
| \\E] 4 ; _c_ ; _spec_ \\E\\
|
||||
: xterm
|
||||
: Change color number _c_ to _spec_, where _spec_ is a color in
|
||||
*XParseColor* format. foot only supports RGB colors; either
|
||||
XParseColor format. foot only supports RGB colors; either
|
||||
*rgb:<red>/<green>/<blue>*, or the legacy format (*#rgb*).
|
||||
| \\E] 7 ; _Uri_ \\E\\
|
||||
: iTerm2
|
||||
|
|
@ -579,7 +579,7 @@ All _OSC_ sequences begin with *\\E]*, sometimes abbreviated _OSC_.
|
|||
| \\E] 10 ; _spec_ \\E\\
|
||||
: xterm
|
||||
: Change the default foreground color to _spec_, a color in
|
||||
*XParseColor* format.
|
||||
XParseColor format.
|
||||
| \\E] 11 ; _spec_ \\E\\
|
||||
: xterm
|
||||
: Change the default background color to _spec_, a color in
|
||||
|
|
@ -588,21 +588,30 @@ All _OSC_ sequences begin with *\\E]*, sometimes abbreviated _OSC_.
|
|||
75% alpha).
|
||||
| \\E] 12 ; _spec_ \\E\\
|
||||
: xterm
|
||||
: Change cursor color to _spec_, a color in *XParseColor* format.
|
||||
: Change cursor color to _spec_, a color in XParseColor format.
|
||||
| \\E] 17 ; _spec_ \\E\\
|
||||
: xterm
|
||||
: Change selection background color to _spec_, a color in
|
||||
XParseColor format.
|
||||
| \\E] 19 ; _spec_ \\E\\
|
||||
: xterm
|
||||
: Change selection foreground color to _spec_, a color in XParseColor
|
||||
format.
|
||||
| \\E] 52 ; _Pc_ ; ? \\E\\
|
||||
: xterm
|
||||
: Send clipboard data. _Pc_ can be either *c*, *s* or *p*. *c* uses
|
||||
the clipboard as source, and *s* and *p* uses the primary
|
||||
selection. The response is *OSC 52 ; Pc ; <base64-encoded data>*,
|
||||
where _Pc_ indicates the source used.
|
||||
where _Pc_ denotes the source used.
|
||||
| \\E] 52 ; _Pc_ ; _Pd_ \\E\\
|
||||
: xterm
|
||||
: Copy _Pd_ (base64 encoded text) to the clipboard. _Pc_ indicates the
|
||||
: Copy _Pd_ (base64 encoded text) to the clipboard. _Pc_ denotes the
|
||||
target: *c* targets the clipboard and *s* and *p* the primary
|
||||
selection.
|
||||
| \\E] 104 [; _c_] \\E\\
|
||||
| \\E] 104 ; _c_ \\E\\
|
||||
: xterm
|
||||
: Reset color number _c_, or all colors (excluding the default
|
||||
: Reset color number _c_ (multiple semicolon separated _c_ values may
|
||||
be provided), or all colors (excluding the default
|
||||
foreground/background colors) if _c_ is omitted.
|
||||
| \\E] 110 \\E\\
|
||||
: xterm
|
||||
|
|
@ -613,6 +622,12 @@ All _OSC_ sequences begin with *\\E]*, sometimes abbreviated _OSC_.
|
|||
| \\E] 112 \\E\\
|
||||
: xterm
|
||||
: Reset cursor color
|
||||
| \\E] 117 \\E\\
|
||||
: xterm
|
||||
: Reset selection background color
|
||||
| \\E] 119 \\E\\
|
||||
: xterm
|
||||
: Reset selection foreground color
|
||||
| \\E] 555 \\E\\
|
||||
: foot
|
||||
: Flash the entire terminal (foot extension)
|
||||
|
|
|
|||
34
osc.c
34
osc.c
|
|
@ -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;
|
||||
|
|
|
|||
6
render.c
6
render.c
|
|
@ -416,9 +416,9 @@ render_cell(struct terminal *term, pixman_image_t *pix,
|
|||
uint32_t _fg = 0;
|
||||
uint32_t _bg = 0;
|
||||
|
||||
if (is_selected && term->conf->colors.use_custom.selection) {
|
||||
_fg = term->conf->colors.selection_fg;
|
||||
_bg = term->conf->colors.selection_bg;
|
||||
if (is_selected && term->colors.use_custom_selection) {
|
||||
_fg = term->colors.selection_fg;
|
||||
_bg = term->colors.selection_bg;
|
||||
} else {
|
||||
/* Use cell specific color, if set, otherwise the default colors (possible reversed) */
|
||||
_fg = cell->attrs.have_fg ? cell->attrs.fg : term->colors.fg;
|
||||
|
|
|
|||
|
|
@ -1087,6 +1087,9 @@ term_init(const struct config *conf, struct fdm *fdm, struct reaper *reaper,
|
|||
.fg = conf->colors.fg,
|
||||
.bg = conf->colors.bg,
|
||||
.alpha = conf->colors.alpha,
|
||||
.selection_fg = conf->colors.selection_fg,
|
||||
.selection_bg = conf->colors.selection_bg,
|
||||
.use_custom_selection = conf->colors.use_custom.selection,
|
||||
},
|
||||
.origin = ORIGIN_ABSOLUTE,
|
||||
.cursor_style = conf->cursor.style,
|
||||
|
|
@ -1683,6 +1686,9 @@ term_reset(struct terminal *term, bool hard)
|
|||
term->colors.fg = term->conf->colors.fg;
|
||||
term->colors.bg = term->conf->colors.bg;
|
||||
term->colors.alpha = term->conf->colors.alpha;
|
||||
term->colors.selection_fg = term->conf->colors.selection_fg;
|
||||
term->colors.selection_bg = term->conf->colors.selection_bg;
|
||||
term->colors.use_custom_selection = term->conf->colors.use_custom.selection;
|
||||
memcpy(term->colors.table, term->conf->colors.table,
|
||||
sizeof(term->colors.table));
|
||||
term->origin = ORIGIN_ABSOLUTE;
|
||||
|
|
|
|||
|
|
@ -407,6 +407,9 @@ struct terminal {
|
|||
uint32_t bg;
|
||||
uint32_t table[256];
|
||||
uint16_t alpha;
|
||||
uint32_t selection_fg;
|
||||
uint32_t selection_bg;
|
||||
bool use_custom_selection;
|
||||
} colors;
|
||||
|
||||
enum cursor_style cursor_style;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue