Skip to content

Instantly share code, notes, and snippets.

@saitoha
Created January 19, 2016 14:35
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save saitoha/ee8e1c886574858843e5 to your computer and use it in GitHub Desktop.
Save saitoha/ee8e1c886574858843e5 to your computer and use it in GitHub Desktop.
GNU Screen: Support OSC 11 sequence (set background color)
diff -ur ansi.c ansi.c
--- ansi.c 2015-04-08 14:34:29.000000000 +0900
+++ ansi.c 2016-01-19 23:23:20.000000000 +0900
@@ -1554,12 +1554,10 @@
}
#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);
@@ -1571,7 +1569,7 @@
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])
+ if ((typ2 == 3 || typ2 == 4) && D_xtermosc[typ2])
Redisplay(0);
}
}
diff -ur display.c display.c
--- display.c 2015-04-08 14:34:29.000000000 +0900
+++ display.c 2016-01-19 23:34:03.000000000 +0900
@@ -2883,6 +2883,7 @@
{
static char *oscs[][2] = {
{ WT_FLAG ";", "screen" }, /* set window title */
+ { "11;", "" }, /* background */
{ "20;", "" }, /* background */
{ "39;", "black" }, /* default foreground (black?) */
{ "49;", "white" } /* default background (white?) */
@@ -2910,7 +2911,7 @@
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 -ur process.c process.c
--- process.c 2015-04-08 14:34:29.000000000 +0900
+++ process.c 2016-01-19 23:25:21.000000000 +0900
@@ -7036,7 +7036,7 @@
D_other = 0;
flayer = D_forecv->c_layer;
#ifdef RXVT_OSC
- if (D_xtermosc[2] || D_xtermosc[3])
+ if (D_xtermosc[3] || D_xtermosc[4])
{
Activate(-1);
}
@@ -7063,7 +7063,7 @@
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
diff -ur window.h window.h
--- window.h 2015-04-08 14:34:29.000000000 +0900
+++ window.h 2016-01-19 23:29:35.000000000 +0900
@@ -232,7 +232,7 @@
char w_vbwait;
char w_norefresh; /* dont redisplay when switching to that win */
#ifdef RXVT_OSC
- char w_xtermosc[4][MAXSTR]; /* special xterm/rxvt escapes */
+ char w_xtermosc[5][MAXSTR]; /* special xterm/rxvt escapes */
#endif
int w_mouse; /* mouse mode 0,9,1000 */
#ifdef HAVE_BRAILLE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment