mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-04 04:06:06 -05:00
osc: implement OSC 12 and OSC 112 (set/reset text cursor color)
This commit is contained in:
parent
97afba1b14
commit
5d702e6fbf
2 changed files with 30 additions and 0 deletions
|
|
@ -26,6 +26,8 @@ foot+base|foot base fragment,
|
|||
it#8,
|
||||
lines#24,
|
||||
pairs#0x10000,
|
||||
Cr=\E]112\007,
|
||||
Cs=\E]12;%p1%s\007,
|
||||
acsc=``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
|
||||
bel=^G,
|
||||
blink=\E[5m,
|
||||
|
|
|
|||
28
osc.c
28
osc.c
|
|
@ -502,6 +502,27 @@ osc_dispatch(struct terminal *term)
|
|||
}
|
||||
|
||||
case 12: /* Set cursor color */
|
||||
|
||||
/* Client queried for current value */
|
||||
if (strlen(string) == 1 && string[0] == '?') {
|
||||
uint8_t r = (term->cursor_color.text >> 16) & 0xff;
|
||||
uint8_t g = (term->cursor_color.text >> 8) & 0xff;
|
||||
uint8_t b = (term->cursor_color.text >> 0) & 0xff;
|
||||
|
||||
char reply[32];
|
||||
snprintf(reply, sizeof(reply), "\033]12;rgb:%02x/%02x/%02x\033\\", r, g, b);
|
||||
term_to_slave(term, reply, strlen(reply));
|
||||
break;
|
||||
}
|
||||
|
||||
uint32_t color;
|
||||
if (string[0] == '#' ? !parse_legacy_color(string, &color) : !parse_rgb(string, &color))
|
||||
break;
|
||||
|
||||
LOG_INFO("change cursor color to %06x", color);
|
||||
|
||||
term->cursor_color.cursor = 1 << 31 | color;
|
||||
render_refresh(term);
|
||||
break;
|
||||
|
||||
case 30: /* Set tab title */
|
||||
|
|
@ -557,6 +578,13 @@ osc_dispatch(struct terminal *term)
|
|||
render_refresh(term);
|
||||
break;
|
||||
|
||||
case 112:
|
||||
LOG_DBG("resetting cursor color");
|
||||
term->cursor_color.text = term->default_cursor_color.text;
|
||||
term->cursor_color.cursor = term->default_cursor_color.cursor;
|
||||
render_refresh(term);
|
||||
break;
|
||||
|
||||
case 555:
|
||||
osc_flash(term);
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue