From f2608bf4c9092300f91330085e839852b4c62155 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Fri, 19 Jul 2019 10:18:22 +0200 Subject: [PATCH] osc: foreground/background reply is now in correct XParseColor format The format we used previously was a discouraged and obsolete format (and incorrect too). --- osc.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/osc.c b/osc.c index 21ee67c0..c85440a8 100644 --- a/osc.c +++ b/osc.c @@ -16,11 +16,20 @@ osc_query(struct terminal *term, unsigned param) switch (param) { case 10: case 11: { - char reply[16]; + uint32_t color = param == 10 ? term->foreground : term->background; + uint8_t r = (color >> 16) & 0xff; + uint8_t g = (color >> 8) & 0xff; + uint8_t b = (color >> 0) & 0xff; + + /* + * Reply in XParseColor format + * E.g. for color 0xdcdccc we reply "\e]10;rgb:dc/dc/cc\e\\" + */ + char reply[32]; snprintf( - reply, sizeof(reply), "\033]%u;%06x\033\\", - param, - (param == 10 ? term->foreground : term->background) & 0xffffff); + reply, sizeof(reply), "\033]%u;rgb:%02x/%02x/%02x\033\\", + param, r, g, b); + vt_to_slave(term, reply, strlen(reply)); break; }