diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2019-07-19 08:18:22 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2019-07-19 08:18:22 +0000 |
| commit | f2608bf4c9092300f91330085e839852b4c62155 (patch) | |
| tree | 604b1d49af27afcb9953d93305be891c2f8376de | |
| parent | csi: recognize DECRQM (CSI ? Ps $ p) (diff) | |
osc: foreground/background reply is now in correct XParseColor format
The format we used previously was a discouraged and obsolete
format (and incorrect too).
| -rw-r--r-- | osc.c | 17 |
1 files changed, 13 insertions, 4 deletions
@@ -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; } |
