diff src/term.c @ 14479:3375a8cbb442 v8.1.0253

patch 8.1.0253: saving and restoring window title does not always work commit https://github.com/vim/vim/commit/40385dbcdfb44885f2e9b83e1e0285aeb8a0c2a8 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Aug 7 22:31:44 2018 +0200 patch 8.1.0253: saving and restoring window title does not always work Problem: Saving and restoring window title does not always work. Solution: Use the stack push and pop commands. (Kouichi Iwamoto, closes #3059)
author Christian Brabandt <cb@256bit.org>
date Tue, 07 Aug 2018 22:45:06 +0200
parents 65b222617852
children 33d751f40e4c
line wrap: on
line diff
--- a/src/term.c
+++ b/src/term.c
@@ -922,6 +922,10 @@ static struct builtin_term builtin_termc
 #  endif
     {(int)KS_CBE,	IF_EB("\033[?2004h", ESC_STR "[?2004h")},
     {(int)KS_CBD,	IF_EB("\033[?2004l", ESC_STR "[?2004l")},
+    {(int)KS_CST,	IF_EB("\033[22;2t", ESC_STR "[22;2t")},
+    {(int)KS_CRT,	IF_EB("\033[23;2t", ESC_STR "[23;2t")},
+    {(int)KS_SSI,	IF_EB("\033[22;1t", ESC_STR "[22;1t")},
+    {(int)KS_SRI,	IF_EB("\033[23;1t", ESC_STR "[23;1t")},
 
     {K_UP,		IF_EB("\033O*A", ESC_STR "O*A")},
     {K_DOWN,		IF_EB("\033O*B", ESC_STR "O*B")},
@@ -1600,6 +1604,8 @@ get_term_entries(int *height, int *width
 			{KS_8F, "8f"}, {KS_8B, "8b"},
 			{KS_CBE, "BE"}, {KS_CBD, "BD"},
 			{KS_CPS, "PS"}, {KS_CPE, "PE"},
+			{KS_CST, "ST"}, {KS_CRT, "RT"},
+			{KS_SSI, "Si"}, {KS_SRI, "Ri"},
 			{(enum SpecialKey)0, NULL}
 		    };
     int		    i;
@@ -2974,6 +2980,45 @@ term_settitle(char_u *title)
     out_str(T_FS);			/* set title end */
     out_flush();
 }
+
+/*
+ * Tell the terminal to push (save) the title and/or icon, so that it can be
+ * popped (restored) later.
+ */
+    void
+term_push_title(int which)
+{
+    if ((which & SAVE_RESTORE_TITLE) && *T_CST != NUL)
+    {
+	OUT_STR(T_CST);
+	out_flush();
+    }
+
+    if ((which & SAVE_RESTORE_ICON) && *T_SSI != NUL)
+    {
+	OUT_STR(T_SSI);
+	out_flush();
+    }
+}
+
+/*
+ * Tell the terminal to pop the title and/or icon.
+ */
+    void
+term_pop_title(int which)
+{
+    if ((which & SAVE_RESTORE_TITLE) && *T_CRT != NUL)
+    {
+	OUT_STR(T_CRT);
+	out_flush();
+    }
+
+    if ((which & SAVE_RESTORE_ICON) && *T_SRI != NUL)
+    {
+	OUT_STR(T_SRI);
+	out_flush();
+    }
+}
 #endif
 
 /*