diff options
author | Lubomir Rintel <lkundrak@v3.sk> | 2018-09-10 19:34:02 +0200 |
---|---|---|
committer | Amadeusz Sławiński <amade@asmblr.net> | 2018-11-18 16:00:25 +0100 |
commit | c5db181b6e017cfccb8d7842ce140e59294d9f62 (patch) | |
tree | 01ff13fec86e85098dcb714579828c224d0979c4 | |
parent | ee12d36719921deb37762f30c91ac7f9c074ce7c (diff) | |
download | screen-c5db181b6e017cfccb8d7842ce140e59294d9f62.tar.gz |
ansi: add support for xterm OSC 11
It allows for getting and setting the background color. Notably, Vim uses
OSC 11 to learn whether it's running on a light or dark colored terminal
and choose a color scheme accordingly.
Tested with gnome-terminal and xterm. When called with "?" argument the
current background color is returned:
$ echo -ne "\e]11;?\e\\"
$ 11;rgb:2323/2727/2929
Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
(cherry picked from commit 7059bff20a28778f9d3acf81cad07b1388d02309)
Signed-off-by: Amadeusz Sławiński <amade@asmblr.net
-rw-r--r-- | src/ansi.c | 17 | ||||
-rw-r--r-- | src/display.c | 3 | ||||
-rw-r--r-- | src/process.c | 2 |
3 files changed, 13 insertions, 9 deletions
@@ -1562,25 +1562,28 @@ StringEnd() } #endif #ifdef RXVT_OSC - if (typ == 0 || typ == 1 || typ == 2 || typ == 20 || typ == 39 || typ == 49) + if (typ == 0 || typ == 1 || typ == 2 || typ == 11 || typ == 20 || typ == 39 || typ == 49) { int typ2; typ2 = typ / 10; - if (--typ2 < 0) - typ2 = 0; if (strcmp(curr->w_xtermosc[typ2], p)) { - strncpy(curr->w_xtermosc[typ2], p, sizeof(curr->w_xtermosc[typ2]) - 1); - curr->w_xtermosc[typ2][sizeof(curr->w_xtermosc[typ2]) - 1] = 0; + if (typ != 11 || strcmp("?", p)) + { + strncpy(curr->w_xtermosc[typ2], p, sizeof(curr->w_xtermosc[typ2]) - 1); + curr->w_xtermosc[typ2][sizeof(curr->w_xtermosc[typ2]) - 1] = 0; + } for (display = displays; display; display = display->d_next) { if (!D_CXT) continue; if (D_forecv->c_layer->l_bottom == &curr->w_layer) - SetXtermOSC(typ2, curr->w_xtermosc[typ2]); - if ((typ2 == 2 || typ2 == 3) && D_xtermosc[typ2]) + SetXtermOSC(typ2, p); + if ((typ2 == 3 || typ2 == 4) && D_xtermosc[typ2]) Redisplay(0); + if (typ == 11 && !strcmp("?", p)) + break; } } } diff --git a/src/display.c b/src/display.c index 190d418..dbc7d74 100644 --- a/src/display.c +++ b/src/display.c @@ -2939,6 +2939,7 @@ char *s; { static char *oscs[][2] = { { WT_FLAG ";", "screen" }, /* set window title */ + { "11;", ""}, /* background RGB */ { "20;", "" }, /* background */ { "39;", "black" }, /* default foreground (black?) */ { "49;", "white" } /* default background (white?) */ @@ -2966,7 +2967,7 @@ void ClearAllXtermOSC() { int i; - for (i = 3; i >= 0; i--) + for (i = 4; i >= 0; i--) SetXtermOSC(i, 0); if (D_xtermosc[0]) AddStr("\033[23;" WT_FLAG "t"); /* unstack titles (xterm patch #251) */ diff --git a/src/process.c b/src/process.c index ec5a911..3c7cce8 100644 --- a/src/process.c +++ b/src/process.c @@ -7190,7 +7190,7 @@ RefreshXtermOSC() struct win *p; p = Layer2Window(D_forecv->c_layer); - for (i = 3; i >=0; i--) + for (i = 4; i >=0; i--) SetXtermOSC(i, p ? p->w_xtermosc[i] : 0); } #endif |