diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2020-01-20 17:36:19 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2020-01-20 17:36:19 +0000 |
| commit | 5d702e6fbf75a1e0427694edc3d86f5a48e6a4cb (patch) | |
| tree | a473c6edc64d0555d6c3853d60c794488f9da3d4 /osc.c | |
| parent | dcs: remove assert; handler may be zero on unimplemented OCS command (diff) | |
osc: implement OSC 12 and OSC 112 (set/reset text cursor color)
Diffstat (limited to 'osc.c')
| -rw-r--r-- | osc.c | 28 |
1 files changed, 28 insertions, 0 deletions
@@ -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; |
