From 5d4a002413cdf09aa471e29b0a7ae29f7cf7b89c Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Mon, 1 Jul 2024 17:24:50 +0200 Subject: osc: merge OSC 10/11/12/17/19 handling 10/11/17/19 were already merged, so this patch just stops special casing 12 (cursor color). In preparation for XTPUSHCOLORS/XTPOPCOLORS, the cursor colors are moved from their own struct, into the 'colors' struct. Also fix a bug where OSC 17/19 queries returned OSC-11 data. --- osc.c | 67 +++++++++++++++++++++++-------------------------------------------- 1 file changed, 23 insertions(+), 44 deletions(-) (limited to 'osc.c') diff --git a/osc.c b/osc.c index 546421f5..ff52fbca 100644 --- a/osc.c +++ b/osc.c @@ -712,15 +712,25 @@ osc_dispatch(struct terminal *term) osc_notify(term, string); break; - case 10: - case 11: - case 17: - case 19: { + case 10: /* fg */ + case 11: /* bg */ + case 12: /* cursor */ + case 17: /* highlight (selection) fg */ + case 19: { /* highlight (selection) bg */ /* Set default foreground/background/highlight-bg/highlight-fg color */ /* Client queried for current value */ if (string[0] == '?' && string[1] == '\0') { - uint32_t color = param == 10 ? term->colors.fg : term->colors.bg; + uint32_t color = param == 10 + ? term->colors.fg + : param == 11 + ? term->colors.bg + : param == 12 + ? term->colors.cursor_bg + : param == 17 + ? term->colors.selection_bg + : term->colors.selection_fg; + uint8_t r = (color >> 16) & 0xff; uint8_t g = (color >> 8) & 0xff; uint8_t b = (color >> 0) & 0xff; @@ -754,6 +764,7 @@ osc_dispatch(struct terminal *term) LOG_DBG("change color definition for %s to %06x", param == 10 ? "foreground" : param == 11 ? "background" : + param == 12 ? "cursor" : param == 17 ? "selection background" : "selection foreground", color); @@ -776,6 +787,11 @@ osc_dispatch(struct terminal *term) } break; + case 12: + term->colors.cursor_bg = 1u << 31 | color; + term_damage_cursor(term); + break; + case 17: term->colors.selection_bg = color; term->colors.use_custom_selection = true; @@ -792,43 +808,6 @@ osc_dispatch(struct terminal *term) break; } - case 12: /* Set cursor color */ - - /* Client queried for current value */ - if (string[0] == '?' && string[1] == '\0') { - uint8_t r = (term->cursor_color.cursor >> 16) & 0xff; - uint8_t g = (term->cursor_color.cursor >> 8) & 0xff; - uint8_t b = (term->cursor_color.cursor >> 0) & 0xff; - const char *terminator = term->vt.osc.bel ? "\a" : "\033\\"; - - char reply[32]; - size_t n = xsnprintf( - reply, sizeof(reply), "\033]12;rgb:%02x/%02x/%02x%s", - r, g, b, terminator); - - term_to_slave(term, reply, n); - break; - } - - uint32_t color; - - if (string[0] == '#' || string[0] == '[' - ? !parse_legacy_color(string, &color, NULL, NULL) - : !parse_rgb(string, &color, NULL, NULL)) - { - break; - } - - LOG_DBG("change cursor color to %06x", color); - - if (color == 0) - term->cursor_color.cursor = 0; /* Invert fg/bg */ - else - term->cursor_color.cursor = 1u << 31 | color; - - term_damage_cursor(term); - break; - case 22: /* Set mouse cursor */ term_set_user_mouse_cursor(term, string); break; @@ -895,8 +874,8 @@ osc_dispatch(struct terminal *term) case 112: LOG_DBG("resetting cursor color"); - term->cursor_color.text = term->conf->cursor.color.text; - term->cursor_color.cursor = term->conf->cursor.color.cursor; + term->colors.cursor_fg = term->conf->cursor.color.text; + term->colors.cursor_bg = term->conf->cursor.color.cursor; term_damage_cursor(term); break; -- cgit v1.3 From d440d5aa2c31e673e0b4fe5c8db41486ae706391 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Mon, 1 Jul 2024 19:29:28 +0200 Subject: osc: 10/11/12/17/19: don't apply overly much damage --- osc.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'osc.c') diff --git a/osc.c b/osc.c index ff52fbca..d9e952c0 100644 --- a/osc.c +++ b/osc.c @@ -772,6 +772,7 @@ osc_dispatch(struct terminal *term) switch (param) { case 10: term->colors.fg = color; + term_damage_view(term); break; case 11: @@ -785,6 +786,8 @@ osc_dispatch(struct terminal *term) term_font_subpixel_changed(term); } } + term_damage_view(term); + term_damage_margins(term); break; case 12: @@ -795,16 +798,16 @@ osc_dispatch(struct terminal *term) case 17: term->colors.selection_bg = color; term->colors.use_custom_selection = true; + term_damage_view(term); break; case 19: term->colors.selection_fg = color; term->colors.use_custom_selection = true; + term_damage_view(term); break; } - term_damage_view(term); - term_damage_margins(term); break; } -- cgit v1.3