1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
|
To: vim_dev@googlegroups.com
Subject: Patch 8.1.0253
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------
Patch 8.1.0253
Problem: Saving and restoring window title does not always work.
Solution: Use the stack push and pop commands. (Kouichi Iwamoto,
closes #3059)
Files: runtime/doc/term.txt, src/main.c, src/option.c, src/os_unix.c,
src/proto/term.pro, src/term.c, src/term.h, src/vim.h,
src/buffer.c, src/ex_docmd.c, src/os_amiga.c,
src/os_mswin.c, src/os_win32.c
*** ../vim-8.1.0252/runtime/doc/term.txt 2018-05-17 13:42:03.000000000 +0200
--- runtime/doc/term.txt 2018-08-07 22:02:48.947042241 +0200
***************
*** 342,347 ****
--- 352,361 ----
t_SH set cursor shape *t_SH* *'t_SH'*
t_RC request terminal cursor blinking *t_RC* *'t_RC'*
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
by the termcap option, the middle part is text.
*** ../vim-8.1.0252/src/main.c 2018-07-29 17:35:19.497750288 +0200
--- src/main.c 2018-08-07 22:11:50.444370658 +0200
***************
*** 706,711 ****
--- 706,715 ----
scroll_region_reset(); /* In case Rows changed */
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.
*/
*** ../vim-8.1.0252/src/option.c 2018-07-23 04:11:37.652969757 +0200
--- src/option.c 2018-08-07 22:26:59.391401674 +0200
***************
*** 3192,3198 ****
--- 3192,3200 ----
p_term("t_RB", T_RBG)
p_term("t_RC", T_CRC)
p_term("t_RI", T_CRI)
+ p_term("t_Ri", T_SRI)
p_term("t_RS", T_CRS)
+ p_term("t_RT", T_CRT)
p_term("t_RV", T_CRV)
p_term("t_Sb", T_CSB)
p_term("t_SC", T_CSC)
***************
*** 3200,3208 ****
--- 3202,3212 ----
p_term("t_Sf", T_CSF)
p_term("t_SH", T_CSH)
p_term("t_SI", T_CSI)
+ p_term("t_Si", T_SSI)
p_term("t_so", T_SO)
p_term("t_SR", T_CSR)
p_term("t_sr", T_SR)
+ p_term("t_ST", T_CST)
p_term("t_Te", T_STE)
p_term("t_te", T_TE)
p_term("t_ti", T_TI)
***************
*** 10414,10420 ****
mch_setmouse(FALSE); /* switch mouse off */
#endif
#ifdef FEAT_TITLE
! mch_restore_title(3); /* restore window titles */
#endif
#if defined(FEAT_XCLIPBOARD) && defined(FEAT_GUI)
/* When starting the GUI close the display opened for the clipboard.
--- 10418,10424 ----
mch_setmouse(FALSE); /* switch mouse off */
#endif
#ifdef FEAT_TITLE
! mch_restore_title(SAVE_RESTORE_BOTH); /* restore window titles */
#endif
#if defined(FEAT_XCLIPBOARD) && defined(FEAT_GUI)
/* When starting the GUI close the display opened for the clipboard.
***************
*** 11219,11226 ****
buf->b_p_isk = NULL;
}
/*
! * Always free the allocated strings.
! * If not already initialized, set 'readonly' and copy 'fileformat'.
*/
if (!buf->b_p_initialized)
{
--- 11223,11230 ----
buf->b_p_isk = NULL;
}
/*
! * Always free the allocated strings. If not already initialized,
! * reset 'readonly' and copy 'fileformat'.
*/
if (!buf->b_p_initialized)
{
*** ../vim-8.1.0252/src/os_unix.c 2018-08-07 17:38:36.991674646 +0200
--- src/os_unix.c 2018-08-07 22:15:19.147259744 +0200
***************
*** 2336,2352 ****
/*
* Restore the window/icon title.
* "which" is one of:
! * 1 only restore title
! * 2 only restore icon
! * 3 restore title and icon
*/
void
mch_restore_title(int which)
{
/* only restore the title or icon when it has been set */
! mch_settitle(((which & 1) && did_set_title) ?
(oldtitle ? oldtitle : p_titleold) : NULL,
! ((which & 2) && did_set_icon) ? oldicon : NULL);
}
#endif /* FEAT_TITLE */
--- 2336,2356 ----
/*
* Restore the window/icon title.
* "which" is one of:
! * SAVE_RESTORE_TITLE only restore title
! * SAVE_RESTORE_ICON only restore icon
! * SAVE_RESTORE_BOTH restore title and icon
*/
void
mch_restore_title(int which)
{
/* only restore the title or icon when it has been set */
! mch_settitle(((which & SAVE_RESTORE_TITLE) && did_set_title) ?
(oldtitle ? oldtitle : p_titleold) : 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 */
***************
*** 3412,3418 ****
{
settmode(TMODE_COOK);
#ifdef FEAT_TITLE
! mch_restore_title(3); /* restore xterm title and icon name */
#endif
/*
* When t_ti is not empty but it doesn't cause swapping terminal
--- 3416,3424 ----
{
settmode(TMODE_COOK);
#ifdef FEAT_TITLE
! // restore xterm title and icon name
! mch_restore_title(SAVE_RESTORE_BOTH);
! term_pop_title(SAVE_RESTORE_BOTH);
#endif
/*
* When t_ti is not empty but it doesn't cause swapping terminal
*** ../vim-8.1.0252/src/proto/term.pro 2018-08-07 17:38:36.995674625 +0200
--- src/proto/term.pro 2018-08-07 22:14:11.971620330 +0200
***************
*** 31,36 ****
--- 31,38 ----
void term_fg_rgb_color(guicolor_T rgb);
void term_bg_rgb_color(guicolor_T rgb);
void term_settitle(char_u *title);
+ void term_push_title(int which);
+ void term_pop_title(int which);
void ttest(int pairs);
void add_long_to_buf(long_u val, char_u *dst);
void check_shellsize(void);
*** ../vim-8.1.0252/src/term.c 2018-08-07 17:38:36.995674625 +0200
--- src/term.c 2018-08-07 22:13:41.603782475 +0200
***************
*** 922,927 ****
--- 922,931 ----
# 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,1605 ****
--- 1604,1611 ----
{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,2979 ****
--- 2980,3024 ----
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
/*
*** ../vim-8.1.0252/src/term.h 2017-10-14 22:14:45.000000000 +0200
--- src/term.h 2018-08-07 22:02:48.951042224 +0200
***************
*** 101,110 ****
KS_CBE, /* enable bracketed paste mode */
KS_CBD, /* disable bracketed paste mode */
KS_CPS, /* start of bracketed paste */
! KS_CPE /* end of bracketed paste */
};
! #define KS_LAST KS_CPE
/*
* the terminal capabilities are stored in this array
--- 101,114 ----
KS_CBE, /* enable bracketed paste mode */
KS_CBD, /* disable bracketed paste mode */
KS_CPS, /* start 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_SRI
/*
* the terminal capabilities are stored in this array
***************
*** 196,201 ****
--- 200,209 ----
#define T_BD (TERM_STR(KS_CBD)) /* disable bracketed paste mode */
#define T_PS (TERM_STR(KS_CPS)) /* start 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_SLEEP 1 /* terminal mode for sleeping (cooked but no echo) */
*** ../vim-8.1.0252/src/vim.h 2018-07-29 16:09:14.644945560 +0200
--- src/vim.h 2018-08-07 22:14:06.727648372 +0200
***************
*** 2548,2551 ****
--- 2548,2563 ----
#define TERM_START_FORCEIT 2
#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 */
*** ../vim-8.1.0252/src/buffer.c 2018-08-05 13:22:22.474562651 +0200
--- src/buffer.c 2018-08-07 22:15:46.499112220 +0200
***************
*** 3798,3804 ****
if (str == NULL)
{
*last = NULL;
! mch_restore_title(last == &lasttitle ? 1 : 2);
}
else
{
--- 3798,3805 ----
if (str == NULL)
{
*last = NULL;
! mch_restore_title(
! last == &lasttitle ? SAVE_RESTORE_TITLE : SAVE_RESTORE_ICON);
}
else
{
*** ../vim-8.1.0252/src/ex_docmd.c 2018-08-01 17:53:04.689381294 +0200
--- src/ex_docmd.c 2018-08-07 22:16:05.727008287 +0200
***************
*** 7750,7756 ****
stoptermcap();
out_flush(); /* needed for SUN to restore xterm buffer */
#ifdef FEAT_TITLE
! mch_restore_title(3); /* restore window titles */
#endif
ui_suspend(); /* call machine specific function */
#ifdef FEAT_TITLE
--- 7750,7756 ----
stoptermcap();
out_flush(); /* needed for SUN to restore xterm buffer */
#ifdef FEAT_TITLE
! mch_restore_title(SAVE_RESTORE_BOTH); /* restore window titles */
#endif
ui_suspend(); /* call machine specific function */
#ifdef FEAT_TITLE
*** ../vim-8.1.0252/src/os_amiga.c 2018-03-04 16:16:34.000000000 +0100
--- src/os_amiga.c 2018-08-07 22:17:36.474515466 +0200
***************
*** 617,630 ****
/*
* Restore the window/icon title.
* which is one of:
! * 1 Just restore title
! * 2 Just restore icon (which we don't have)
! * 3 Restore title and icon (which we don't have)
*/
void
mch_restore_title(int which)
{
! if (which & 1)
mch_settitle(oldwindowtitle, NULL);
}
--- 617,630 ----
/*
* Restore the window/icon title.
* which is one of:
! * SAVE_RESTORE_TITLE Just restore title
! * SAVE_RESTORE_ICON Just restore icon (which we don't have)
! * SAVE_RESTORE_BOTH Restore title and icon (which we don't have)
*/
void
mch_restore_title(int which)
{
! if (which & SAVE_RESTORE_TITLE)
mch_settitle(oldwindowtitle, NULL);
}
***************
*** 907,913 ****
}
#ifdef FEAT_TITLE
! mch_restore_title(3); /* restore window title */
#endif
ml_close_all(TRUE); /* remove all memfiles */
--- 907,913 ----
}
#ifdef FEAT_TITLE
! mch_restore_title(SAVE_RESTORE_BOTH); /* restore window title */
#endif
ml_close_all(TRUE); /* remove all memfiles */
*** ../vim-8.1.0252/src/os_mswin.c 2018-05-13 17:28:51.000000000 +0200
--- src/os_mswin.c 2018-08-07 22:18:09.022337873 +0200
***************
*** 304,312 ****
/*
* Restore the window/icon title.
* which is one of:
! * 1: Just restore title
! * 2: Just restore icon (which we don't have)
! * 3: Restore title and icon (which we don't have)
*/
void
mch_restore_title(int which UNUSED)
--- 304,312 ----
/*
* Restore the window/icon title.
* which is one of:
! * SAVE_RESTORE_TITLE: Just restore title
! * SAVE_RESTORE_ICON: Just restore icon (which we don't have)
! * SAVE_RESTORE_BOTH: Restore title and icon (which we don't have)
*/
void
mch_restore_title(int which UNUSED)
*** ../vim-8.1.0252/src/os_win32.c 2018-08-07 20:47:02.756848221 +0200
--- src/os_win32.c 2018-08-07 22:18:29.258227246 +0200
***************
*** 2695,2701 ****
if (g_fWindInitCalled)
{
#ifdef FEAT_TITLE
! mch_restore_title(3);
/*
* 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
--- 2695,2701 ----
if (g_fWindInitCalled)
{
#ifdef FEAT_TITLE
! mch_restore_title(SAVE_RESTORE_BOTH);
/*
* 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
*** ../vim-8.1.0252/src/version.c 2018-08-07 21:54:27.725813349 +0200
--- src/version.c 2018-08-07 22:04:25.166600764 +0200
***************
*** 796,797 ****
--- 796,799 ----
{ /* Add new patch number below this line */
+ /**/
+ 253,
/**/
--
[Autumn changed into Winter ... Winter changed into Spring ... Spring
changed back into Autumn and Autumn gave Winter and Spring a miss and
went straight on into Summer ... Until one day ...]
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|