mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-05 04:06:08 -05:00
osc: foreground/background reply is now in correct XParseColor format
The format we used previously was a discouraged and obsolete format (and incorrect too).
This commit is contained in:
parent
7472e9c152
commit
f2608bf4c9
1 changed files with 13 additions and 4 deletions
17
osc.c
17
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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue