forked from aniani/vim
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)
This commit is contained in:
@@ -352,6 +352,10 @@ Added by Vim (there are no standard codes for these):
|
|||||||
t_SH set cursor shape *t_SH* *'t_SH'*
|
t_SH set cursor shape *t_SH* *'t_SH'*
|
||||||
t_RC request terminal cursor blinking *t_RC* *'t_RC'*
|
t_RC request terminal cursor blinking *t_RC* *'t_RC'*
|
||||||
t_RS request terminal cursor style *t_RS* *'t_RS'*
|
t_RS request terminal cursor style *t_RS* *'t_RS'*
|
||||||
|
t_ST save window title to stack *t_ST* *'t_ST'*
|
||||||
|
t_RT restore window title from stack *t_RT* *'t_RT'*
|
||||||
|
t_Si save icon text to stack *t_Si* *'t_Si'*
|
||||||
|
t_Ri restore icon text from stack *t_Ri* *'t_Ri'*
|
||||||
|
|
||||||
Some codes have a start, middle and end part. The start and end are defined
|
Some codes have a start, middle and end part. The start and end are defined
|
||||||
by the termcap option, the middle part is text.
|
by the termcap option, the middle part is text.
|
||||||
|
|||||||
@@ -3798,7 +3798,8 @@ value_changed(char_u *str, char_u **last)
|
|||||||
if (str == NULL)
|
if (str == NULL)
|
||||||
{
|
{
|
||||||
*last = NULL;
|
*last = NULL;
|
||||||
mch_restore_title(last == &lasttitle ? 1 : 2);
|
mch_restore_title(
|
||||||
|
last == &lasttitle ? SAVE_RESTORE_TITLE : SAVE_RESTORE_ICON);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7750,7 +7750,7 @@ ex_stop(exarg_T *eap)
|
|||||||
stoptermcap();
|
stoptermcap();
|
||||||
out_flush(); /* needed for SUN to restore xterm buffer */
|
out_flush(); /* needed for SUN to restore xterm buffer */
|
||||||
#ifdef FEAT_TITLE
|
#ifdef FEAT_TITLE
|
||||||
mch_restore_title(3); /* restore window titles */
|
mch_restore_title(SAVE_RESTORE_BOTH); /* restore window titles */
|
||||||
#endif
|
#endif
|
||||||
ui_suspend(); /* call machine specific function */
|
ui_suspend(); /* call machine specific function */
|
||||||
#ifdef FEAT_TITLE
|
#ifdef FEAT_TITLE
|
||||||
|
|||||||
@@ -706,6 +706,10 @@ vim_main2(void)
|
|||||||
scroll_region_reset(); /* In case Rows changed */
|
scroll_region_reset(); /* In case Rows changed */
|
||||||
scroll_start(); /* may scroll the screen to the right position */
|
scroll_start(); /* may scroll the screen to the right position */
|
||||||
|
|
||||||
|
#ifdef FEAT_TITLE
|
||||||
|
term_push_title(SAVE_RESTORE_BOTH);
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Don't clear the screen when starting in Ex mode, unless using the GUI.
|
* Don't clear the screen when starting in Ex mode, unless using the GUI.
|
||||||
*/
|
*/
|
||||||
|
|||||||
10
src/option.c
10
src/option.c
@@ -3192,7 +3192,9 @@ static struct vimoption options[] =
|
|||||||
p_term("t_RB", T_RBG)
|
p_term("t_RB", T_RBG)
|
||||||
p_term("t_RC", T_CRC)
|
p_term("t_RC", T_CRC)
|
||||||
p_term("t_RI", T_CRI)
|
p_term("t_RI", T_CRI)
|
||||||
|
p_term("t_Ri", T_SRI)
|
||||||
p_term("t_RS", T_CRS)
|
p_term("t_RS", T_CRS)
|
||||||
|
p_term("t_RT", T_CRT)
|
||||||
p_term("t_RV", T_CRV)
|
p_term("t_RV", T_CRV)
|
||||||
p_term("t_Sb", T_CSB)
|
p_term("t_Sb", T_CSB)
|
||||||
p_term("t_SC", T_CSC)
|
p_term("t_SC", T_CSC)
|
||||||
@@ -3200,9 +3202,11 @@ static struct vimoption options[] =
|
|||||||
p_term("t_Sf", T_CSF)
|
p_term("t_Sf", T_CSF)
|
||||||
p_term("t_SH", T_CSH)
|
p_term("t_SH", T_CSH)
|
||||||
p_term("t_SI", T_CSI)
|
p_term("t_SI", T_CSI)
|
||||||
|
p_term("t_Si", T_SSI)
|
||||||
p_term("t_so", T_SO)
|
p_term("t_so", T_SO)
|
||||||
p_term("t_SR", T_CSR)
|
p_term("t_SR", T_CSR)
|
||||||
p_term("t_sr", T_SR)
|
p_term("t_sr", T_SR)
|
||||||
|
p_term("t_ST", T_CST)
|
||||||
p_term("t_Te", T_STE)
|
p_term("t_Te", T_STE)
|
||||||
p_term("t_te", T_TE)
|
p_term("t_te", T_TE)
|
||||||
p_term("t_ti", T_TI)
|
p_term("t_ti", T_TI)
|
||||||
@@ -10414,7 +10418,7 @@ clear_termoptions(void)
|
|||||||
mch_setmouse(FALSE); /* switch mouse off */
|
mch_setmouse(FALSE); /* switch mouse off */
|
||||||
#endif
|
#endif
|
||||||
#ifdef FEAT_TITLE
|
#ifdef FEAT_TITLE
|
||||||
mch_restore_title(3); /* restore window titles */
|
mch_restore_title(SAVE_RESTORE_BOTH); /* restore window titles */
|
||||||
#endif
|
#endif
|
||||||
#if defined(FEAT_XCLIPBOARD) && defined(FEAT_GUI)
|
#if defined(FEAT_XCLIPBOARD) && defined(FEAT_GUI)
|
||||||
/* When starting the GUI close the display opened for the clipboard.
|
/* When starting the GUI close the display opened for the clipboard.
|
||||||
@@ -11219,8 +11223,8 @@ buf_copy_options(buf_T *buf, int flags)
|
|||||||
buf->b_p_isk = NULL;
|
buf->b_p_isk = NULL;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Always free the allocated strings.
|
* Always free the allocated strings. If not already initialized,
|
||||||
* If not already initialized, set 'readonly' and copy 'fileformat'.
|
* reset 'readonly' and copy 'fileformat'.
|
||||||
*/
|
*/
|
||||||
if (!buf->b_p_initialized)
|
if (!buf->b_p_initialized)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -617,14 +617,14 @@ mch_settitle(char_u *title, char_u *icon)
|
|||||||
/*
|
/*
|
||||||
* Restore the window/icon title.
|
* Restore the window/icon title.
|
||||||
* which is one of:
|
* which is one of:
|
||||||
* 1 Just restore title
|
* SAVE_RESTORE_TITLE Just restore title
|
||||||
* 2 Just restore icon (which we don't have)
|
* SAVE_RESTORE_ICON Just restore icon (which we don't have)
|
||||||
* 3 Restore title and icon (which we don't have)
|
* SAVE_RESTORE_BOTH Restore title and icon (which we don't have)
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
mch_restore_title(int which)
|
mch_restore_title(int which)
|
||||||
{
|
{
|
||||||
if (which & 1)
|
if (which & SAVE_RESTORE_TITLE)
|
||||||
mch_settitle(oldwindowtitle, NULL);
|
mch_settitle(oldwindowtitle, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -907,7 +907,7 @@ mch_exit(int r)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef FEAT_TITLE
|
#ifdef FEAT_TITLE
|
||||||
mch_restore_title(3); /* restore window title */
|
mch_restore_title(SAVE_RESTORE_BOTH); /* restore window title */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ml_close_all(TRUE); /* remove all memfiles */
|
ml_close_all(TRUE); /* remove all memfiles */
|
||||||
|
|||||||
@@ -304,9 +304,9 @@ mch_settitle(
|
|||||||
/*
|
/*
|
||||||
* Restore the window/icon title.
|
* Restore the window/icon title.
|
||||||
* which is one of:
|
* which is one of:
|
||||||
* 1: Just restore title
|
* SAVE_RESTORE_TITLE: Just restore title
|
||||||
* 2: Just restore icon (which we don't have)
|
* SAVE_RESTORE_ICON: Just restore icon (which we don't have)
|
||||||
* 3: Restore title and icon (which we don't have)
|
* SAVE_RESTORE_BOTH: Restore title and icon (which we don't have)
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
mch_restore_title(int which UNUSED)
|
mch_restore_title(int which UNUSED)
|
||||||
|
|||||||
@@ -2336,17 +2336,21 @@ mch_settitle(char_u *title, char_u *icon)
|
|||||||
/*
|
/*
|
||||||
* Restore the window/icon title.
|
* Restore the window/icon title.
|
||||||
* "which" is one of:
|
* "which" is one of:
|
||||||
* 1 only restore title
|
* SAVE_RESTORE_TITLE only restore title
|
||||||
* 2 only restore icon
|
* SAVE_RESTORE_ICON only restore icon
|
||||||
* 3 restore title and icon
|
* SAVE_RESTORE_BOTH restore title and icon
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
mch_restore_title(int which)
|
mch_restore_title(int which)
|
||||||
{
|
{
|
||||||
/* only restore the title or icon when it has been set */
|
/* only restore the title or icon when it has been set */
|
||||||
mch_settitle(((which & 1) && did_set_title) ?
|
mch_settitle(((which & SAVE_RESTORE_TITLE) && did_set_title) ?
|
||||||
(oldtitle ? oldtitle : p_titleold) : NULL,
|
(oldtitle ? oldtitle : p_titleold) : NULL,
|
||||||
((which & 2) && did_set_icon) ? oldicon : NULL);
|
((which & SAVE_RESTORE_ICON) && did_set_icon) ? oldicon : NULL);
|
||||||
|
|
||||||
|
// pop and push from/to the stack
|
||||||
|
term_pop_title(which);
|
||||||
|
term_push_title(which);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* FEAT_TITLE */
|
#endif /* FEAT_TITLE */
|
||||||
@@ -3412,7 +3416,9 @@ mch_exit(int r)
|
|||||||
{
|
{
|
||||||
settmode(TMODE_COOK);
|
settmode(TMODE_COOK);
|
||||||
#ifdef FEAT_TITLE
|
#ifdef FEAT_TITLE
|
||||||
mch_restore_title(3); /* restore xterm title and icon name */
|
// restore xterm title and icon name
|
||||||
|
mch_restore_title(SAVE_RESTORE_BOTH);
|
||||||
|
term_pop_title(SAVE_RESTORE_BOTH);
|
||||||
#endif
|
#endif
|
||||||
/*
|
/*
|
||||||
* When t_ti is not empty but it doesn't cause swapping terminal
|
* When t_ti is not empty but it doesn't cause swapping terminal
|
||||||
|
|||||||
@@ -2695,7 +2695,7 @@ mch_exit(int r)
|
|||||||
if (g_fWindInitCalled)
|
if (g_fWindInitCalled)
|
||||||
{
|
{
|
||||||
#ifdef FEAT_TITLE
|
#ifdef FEAT_TITLE
|
||||||
mch_restore_title(3);
|
mch_restore_title(SAVE_RESTORE_BOTH);
|
||||||
/*
|
/*
|
||||||
* Restore both the small and big icons of the console window to
|
* Restore both the small and big icons of the console window to
|
||||||
* what they were at startup. Don't do this when the window is
|
* what they were at startup. Don't do this when the window is
|
||||||
|
|||||||
@@ -31,6 +31,8 @@ void term_bg_color(int n);
|
|||||||
void term_fg_rgb_color(guicolor_T rgb);
|
void term_fg_rgb_color(guicolor_T rgb);
|
||||||
void term_bg_rgb_color(guicolor_T rgb);
|
void term_bg_rgb_color(guicolor_T rgb);
|
||||||
void term_settitle(char_u *title);
|
void term_settitle(char_u *title);
|
||||||
|
void term_push_title(int which);
|
||||||
|
void term_pop_title(int which);
|
||||||
void ttest(int pairs);
|
void ttest(int pairs);
|
||||||
void add_long_to_buf(long_u val, char_u *dst);
|
void add_long_to_buf(long_u val, char_u *dst);
|
||||||
void check_shellsize(void);
|
void check_shellsize(void);
|
||||||
|
|||||||
45
src/term.c
45
src/term.c
@@ -922,6 +922,10 @@ static struct builtin_term builtin_termcaps[] =
|
|||||||
# endif
|
# endif
|
||||||
{(int)KS_CBE, IF_EB("\033[?2004h", ESC_STR "[?2004h")},
|
{(int)KS_CBE, IF_EB("\033[?2004h", ESC_STR "[?2004h")},
|
||||||
{(int)KS_CBD, IF_EB("\033[?2004l", ESC_STR "[?2004l")},
|
{(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_UP, IF_EB("\033O*A", ESC_STR "O*A")},
|
||||||
{K_DOWN, IF_EB("\033O*B", ESC_STR "O*B")},
|
{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_8F, "8f"}, {KS_8B, "8b"},
|
||||||
{KS_CBE, "BE"}, {KS_CBD, "BD"},
|
{KS_CBE, "BE"}, {KS_CBD, "BD"},
|
||||||
{KS_CPS, "PS"}, {KS_CPE, "PE"},
|
{KS_CPS, "PS"}, {KS_CPE, "PE"},
|
||||||
|
{KS_CST, "ST"}, {KS_CRT, "RT"},
|
||||||
|
{KS_SSI, "Si"}, {KS_SRI, "Ri"},
|
||||||
{(enum SpecialKey)0, NULL}
|
{(enum SpecialKey)0, NULL}
|
||||||
};
|
};
|
||||||
int i;
|
int i;
|
||||||
@@ -2974,6 +2980,45 @@ term_settitle(char_u *title)
|
|||||||
out_str(T_FS); /* set title end */
|
out_str(T_FS); /* set title end */
|
||||||
out_flush();
|
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
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
12
src/term.h
12
src/term.h
@@ -101,10 +101,14 @@ enum SpecialKey
|
|||||||
KS_CBE, /* enable bracketed paste mode */
|
KS_CBE, /* enable bracketed paste mode */
|
||||||
KS_CBD, /* disable bracketed paste mode */
|
KS_CBD, /* disable bracketed paste mode */
|
||||||
KS_CPS, /* start of bracketed paste */
|
KS_CPS, /* start of bracketed paste */
|
||||||
KS_CPE /* end of bracketed paste */
|
KS_CPE, /* end of bracketed paste */
|
||||||
|
KS_CST, /* save window title */
|
||||||
|
KS_CRT, /* restore window title */
|
||||||
|
KS_SSI, /* save icon text */
|
||||||
|
KS_SRI /* restore icon text */
|
||||||
};
|
};
|
||||||
|
|
||||||
#define KS_LAST KS_CPE
|
#define KS_LAST KS_SRI
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* the terminal capabilities are stored in this array
|
* the terminal capabilities are stored in this array
|
||||||
@@ -196,6 +200,10 @@ extern char_u *(term_strings[]); /* current terminal strings */
|
|||||||
#define T_BD (TERM_STR(KS_CBD)) /* disable bracketed paste mode */
|
#define T_BD (TERM_STR(KS_CBD)) /* disable bracketed paste mode */
|
||||||
#define T_PS (TERM_STR(KS_CPS)) /* start of bracketed paste */
|
#define T_PS (TERM_STR(KS_CPS)) /* start of bracketed paste */
|
||||||
#define T_PE (TERM_STR(KS_CPE)) /* end of bracketed paste */
|
#define T_PE (TERM_STR(KS_CPE)) /* end of bracketed paste */
|
||||||
|
#define T_CST (TERM_STR(KS_CST)) /* save window title */
|
||||||
|
#define T_CRT (TERM_STR(KS_CRT)) /* restore window title */
|
||||||
|
#define T_SSI (TERM_STR(KS_SSI)) /* save icon text */
|
||||||
|
#define T_SRI (TERM_STR(KS_SRI)) /* restore icon text */
|
||||||
|
|
||||||
#define TMODE_COOK 0 /* terminal mode for external cmds and Ex mode */
|
#define TMODE_COOK 0 /* terminal mode for external cmds and Ex mode */
|
||||||
#define TMODE_SLEEP 1 /* terminal mode for sleeping (cooked but no echo) */
|
#define TMODE_SLEEP 1 /* terminal mode for sleeping (cooked but no echo) */
|
||||||
|
|||||||
@@ -794,6 +794,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
253,
|
||||||
/**/
|
/**/
|
||||||
252,
|
252,
|
||||||
/**/
|
/**/
|
||||||
|
|||||||
12
src/vim.h
12
src/vim.h
@@ -2548,4 +2548,16 @@ typedef enum {
|
|||||||
#define TERM_START_FORCEIT 2
|
#define TERM_START_FORCEIT 2
|
||||||
#define TERM_START_SYSTEM 4
|
#define TERM_START_SYSTEM 4
|
||||||
|
|
||||||
|
#if defined(HAVE_DROP_FILE) \
|
||||||
|
|| (defined(FEAT_GUI_GTK) && defined(FEAT_DND)) \
|
||||||
|
|| defined(FEAT_GUI_MSWIN) \
|
||||||
|
|| defined(FEAT_GUI_MAC)
|
||||||
|
# define HAVE_HANDLE_DROP
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Used for icon/title save and restore.
|
||||||
|
#define SAVE_RESTORE_TITLE 1
|
||||||
|
#define SAVE_RESTORE_ICON 2
|
||||||
|
#define SAVE_RESTORE_BOTH (SAVE_RESTORE_TITLE | SAVE_RESTORE_ICON)
|
||||||
|
|
||||||
#endif /* VIM__H */
|
#endif /* VIM__H */
|
||||||
|
|||||||
Reference in New Issue
Block a user