aboutsummaryrefslogtreecommitdiff
path: root/osc.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2020-01-20 17:36:19 +0000
committerDaniel Eklöf <daniel@ekloef.se>2020-01-20 17:36:19 +0000
commit5d702e6fbf75a1e0427694edc3d86f5a48e6a4cb (patch)
treea473c6edc64d0555d6c3853d60c794488f9da3d4 /osc.c
parentdcs: 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.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/osc.c b/osc.c
index d327d376..0b1d04d9 100644
--- a/osc.c
+++ b/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;