From d0ebad653b810fbdd9420ff172c238a5ec52eb1f Mon Sep 17 00:00:00 2001 From: Marcelo Lira Date: Sun, 2 Mar 2025 03:36:46 -0300 Subject: CSI 22, 23 This patch adds support for CSI escape sequences 22 and 23, which save and restore window title (for instance nvim does this when opening and closing). https://st.suckless.org/patches/csi_22_23/ --- st.c | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) (limited to 'st.c') diff --git a/st.c b/st.c index 663b20d..ef8a793 100644 --- a/st.c +++ b/st.c @@ -1817,6 +1817,33 @@ csihandle(void) goto unknown; } break; + case 't': /* title stack operations */ + switch (csiescseq.arg[0]) { + case 22: /* pust current title on stack */ + switch (csiescseq.arg[1]) { + case 0: + case 1: + case 2: + xpushtitle(); + break; + default: + goto unknown; + } + break; + case 23: /* pop last title from stack */ + switch (csiescseq.arg[1]) { + case 0: + case 1: + case 2: + xsettitle(NULL, 1); + break; + default: + goto unknown; + } + break; + default: + goto unknown; + } } } @@ -1895,7 +1922,7 @@ strhandle(void) switch (par) { case 0: if (narg > 1) { - xsettitle(strescseq.args[1]); + xsettitle(strescseq.args[1], 0); xseticontitle(strescseq.args[1]); } return; @@ -1905,7 +1932,7 @@ strhandle(void) return; case 2: if (narg > 1) - xsettitle(strescseq.args[1]); + xsettitle(strescseq.args[1], 0); return; case 52: if (narg > 2 && allowwindowops) { @@ -1964,7 +1991,7 @@ strhandle(void) } break; case 'k': /* old title set compatibility */ - xsettitle(strescseq.args[0]); + xsettitle(strescseq.args[0], 0); return; case 'P': /* DCS -- Device Control String */ case '_': /* APC -- Application Program Command */ @@ -2336,6 +2363,7 @@ eschandle(uchar ascii) break; case 'c': /* RIS -- Reset to initial state */ treset(); + xfreetitlestack(); resettitle(); xloadcols(); xsetmode(0, MODE_HIDE); @@ -2631,7 +2659,7 @@ tresize(int col, int row) void resettitle(void) { - xsettitle(NULL); + xsettitle(NULL, 0); } void -- cgit v1.2.3