summaryrefslogtreecommitdiffstats
path: root/patches/source/vim/patches/7.4.389
blob: 6778941a1a1432f1496f450afd34912e5a4528f1 (plain) (blame)
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
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
To: vim_dev@googlegroups.com
Subject: Patch 7.4.389
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------

Patch 7.4.389
Problem:    Still sometimes Vim enters Replace mode when starting up.
Solution:   Use a different solution in detecting the termresponse and
	    location response. (Hayaki Saito)
Files:	    src/globals.h, src/os_unix.c, src/term.c, src/proto/term.pro


*** ../vim-7.4.388/src/globals.h	2014-06-12 14:01:27.575769788 +0200
--- src/globals.h	2014-07-30 17:02:57.711526671 +0200
***************
*** 1336,1344 ****
  #if defined(UNIX) || defined(VMS)
  EXTERN int	term_is_xterm INIT(= FALSE);	/* xterm-like 'term' */
  #endif
- #if defined(UNIX)
- EXTERN int	xterm_conflict_mouse INIT(= FALSE);
- #endif
  
  #ifdef BACKSLASH_IN_FILENAME
  EXTERN char	psepc INIT(= '\\');	/* normal path separator character */
--- 1336,1341 ----
*** ../vim-7.4.388/src/os_unix.c	2014-07-09 19:13:45.007701718 +0200
--- src/os_unix.c	2014-07-30 17:06:02.375525344 +0200
***************
*** 3667,3674 ****
      void
  check_mouse_termcode()
  {
-     xterm_conflict_mouse = FALSE;
- 
  # ifdef FEAT_MOUSE_XTERM
      if (use_xterm_mouse()
  # ifdef FEAT_MOUSE_URXVT
--- 3667,3672 ----
***************
*** 3713,3719 ****
  # endif
  
  # ifdef FEAT_MOUSE_JSB
!     /* There is no conflict, but it was disabled for xterm before. */
      if (!use_xterm_mouse()
  #  ifdef FEAT_GUI
  	    && !gui.in_use
--- 3711,3717 ----
  # endif
  
  # ifdef FEAT_MOUSE_JSB
!     /* Conflicts with xterm mouse: "\033[" and "\033[M" ??? */
      if (!use_xterm_mouse()
  #  ifdef FEAT_GUI
  	    && !gui.in_use
***************
*** 3740,3784 ****
  # endif
  
  # ifdef FEAT_MOUSE_DEC
!     /* Conflicts with xterm mouse: "\033[" and "\033[M".
!      * Also conflicts with the xterm termresponse, skip this if it was
!      * requested already. */
      if (!use_xterm_mouse()
- #  ifdef FEAT_TERMRESPONSE
- 	    && !did_request_esc_sequence()
- #  endif
  #  ifdef FEAT_GUI
  	    && !gui.in_use
  #  endif
  	    )
-     {
  	set_mouse_termcode(KS_DEC_MOUSE, (char_u *)(term_is_8bit(T_NAME)
  		     ? IF_EB("\233", CSI_STR) : IF_EB("\033[", ESC_STR "[")));
- 	xterm_conflict_mouse = TRUE;
-     }
      else
  	del_mouse_termcode(KS_DEC_MOUSE);
  # endif
  # ifdef FEAT_MOUSE_PTERM
!     /* same as the dec mouse */
      if (!use_xterm_mouse()
- #  ifdef FEAT_TERMRESPONSE
- 	    && !did_request_esc_sequence()
- #  endif
  #  ifdef FEAT_GUI
  	    && !gui.in_use
  #  endif
  	    )
-     {
  	set_mouse_termcode(KS_PTERM_MOUSE,
  				      (char_u *) IF_EB("\033[", ESC_STR "["));
- 	xterm_conflict_mouse = TRUE;
-     }
      else
  	del_mouse_termcode(KS_PTERM_MOUSE);
  # endif
  # ifdef FEAT_MOUSE_URXVT
!     /* same as the dec mouse */
      if (use_xterm_mouse() == 3
  #  ifdef FEAT_GUI
  	    && !gui.in_use
--- 3738,3768 ----
  # endif
  
  # ifdef FEAT_MOUSE_DEC
!     /* Conflicts with xterm mouse: "\033[" and "\033[M" */
      if (!use_xterm_mouse()
  #  ifdef FEAT_GUI
  	    && !gui.in_use
  #  endif
  	    )
  	set_mouse_termcode(KS_DEC_MOUSE, (char_u *)(term_is_8bit(T_NAME)
  		     ? IF_EB("\233", CSI_STR) : IF_EB("\033[", ESC_STR "[")));
      else
  	del_mouse_termcode(KS_DEC_MOUSE);
  # endif
  # ifdef FEAT_MOUSE_PTERM
!     /* same conflict as the dec mouse */
      if (!use_xterm_mouse()
  #  ifdef FEAT_GUI
  	    && !gui.in_use
  #  endif
  	    )
  	set_mouse_termcode(KS_PTERM_MOUSE,
  				      (char_u *) IF_EB("\033[", ESC_STR "["));
      else
  	del_mouse_termcode(KS_PTERM_MOUSE);
  # endif
  # ifdef FEAT_MOUSE_URXVT
!     /* same conflict as the dec mouse */
      if (use_xterm_mouse() == 3
  #  ifdef FEAT_GUI
  	    && !gui.in_use
***************
*** 3794,3801 ****
  	    mch_setmouse(FALSE);
  	    setmouse();
  	}
- 	/* It's OK to request the xterm version for uxterm. */
- 	resume_get_esc_sequence();
      }
      else
  	del_mouse_termcode(KS_URXVT_MOUSE);
--- 3778,3783 ----
*** ../vim-7.4.388/src/term.c	2014-07-09 20:51:04.519583033 +0200
--- src/term.c	2014-07-30 17:20:54.915518929 +0200
***************
*** 153,163 ****
  static char_u *vim_tgetstr __ARGS((char *s, char_u **pp));
  #endif /* HAVE_TGETENT */
  
- #if defined(FEAT_TERMRESPONSE)
- static int xt_index_in = 0;
- static int xt_index_out = 0;
- #endif
- 
  static int  detected_8bit = FALSE;	/* detected 8-bit terminal */
  
  static struct builtin_term builtin_termcaps[] =
--- 153,158 ----
***************
*** 3312,3351 ****
  }
  
  #if defined(FEAT_TERMRESPONSE) || defined(PROTO)
- # if defined(UNIX) || defined(PROTO)
- /*
-  * Return TRUE when the xterm version was requested or anything else that
-  * would send an ESC sequence back to Vim.
-  * If not sent yet, prevent it from being sent soon.
-  * Used to check whether it is OK to enable checking for DEC mouse codes,
-  * which conflict with may xterm ESC sequences.
-  */
-     int
- did_request_esc_sequence()
- {
-     if (crv_status == CRV_GET)
- 	crv_status = 0;
-     if (u7_status == U7_GET)
- 	u7_status = 0;
-     return crv_status == CRV_SENT || u7_status == U7_SENT
- 						|| xt_index_out > xt_index_in;
- }
- 
- /*
-  * If requesting the version was disabled in did_request_esc_sequence(),
-  * enable it again.
-  */
-     void
- resume_get_esc_sequence()
- {
-     if (crv_status == 0)
- 	crv_status = CRV_GET;
-     if (u7_status == 0)
- 	u7_status = U7_GET;
- }
- # endif
- 
- 
  /*
   * Request version string (for xterm) when needed.
   * Only do this after switching to raw mode, otherwise the result will be
--- 3307,3312 ----
***************
*** 3358,3365 ****
   * Insert mode.
   * On Unix only do it when both output and input are a tty (avoid writing
   * request to terminal while reading from a file).
-  * Do not do this when a mouse is being detected that starts with the same ESC
-  * sequence as the termresponse.
   * The result is caught in check_termcode().
   */
      void
--- 3319,3324 ----
***************
*** 3373,3379 ****
  # ifdef UNIX
  	    && isatty(1)
  	    && isatty(read_cmd_fd)
- 	    && !xterm_conflict_mouse
  # endif
  	    && *T_CRV != NUL)
      {
--- 3332,3337 ----
***************
*** 3742,3749 ****
  #if defined(WIN3264) && !defined(FEAT_GUI)
      if (s[0] == K_NUL)
      {
!         STRMOVE(s + 1, s);
!         s[1] = 3;
      }
  #endif
  
--- 3700,3707 ----
  #if defined(WIN3264) && !defined(FEAT_GUI)
      if (s[0] == K_NUL)
      {
! 	STRMOVE(s + 1, s);
! 	s[1] = 3;
      }
  #endif
  
***************
*** 4212,4235 ****
  
  #ifdef FEAT_TERMRESPONSE
  	if (key_name[0] == NUL
! 	    /* URXVT mouse uses <ESC>[#;#;#M, but we are matching <ESC>[ */
  	    || key_name[0] == KS_URXVT_MOUSE
- # ifdef FEAT_MBYTE
- 	    || u7_status == U7_SENT
  # endif
!             )
  	{
! 	    /* Check for some responses from terminal start with "<Esc>[" or
! 	     * CSI.
  	     *
! 	     * - xterm version string: <Esc>[>{x};{vers};{y}c
  	     *   Also eat other possible responses to t_RV, rxvt returns
  	     *   "<Esc>[?1;2c". Also accept CSI instead of <Esc>[.
  	     *   mrxvt has been reported to have "+" in the version. Assume
  	     *   the escape sequence ends with a letter or one of "{|}~".
  	     *
! 	     * - cursor position report: <Esc>[{row};{col}R
! 	     *   The final byte is 'R'. now it is only used for checking for
  	     *   ambiguous-width character state.
  	     */
  	    p = tp[0] == CSI ? tp + 1 : tp + 2;
--- 4170,4200 ----
  
  #ifdef FEAT_TERMRESPONSE
  	if (key_name[0] == NUL
! 	    /* Mouse codes of DEC, pterm, and URXVT start with <ESC>[.  When
! 	     * detecting the start of these mouse codes they might as well be
! 	     * another key code or terminal response. */
! # ifdef FEAT_MOUSE_DEC
! 	    || key_name[0] == KS_DEC_MOUSE
! # endif
! # ifdef FEAT_MOUSE_PTERM
! 	    || key_name[0] == KS_PTERM_MOUSE
! # endif
! # ifdef FEAT_MOUSE_URXVT
  	    || key_name[0] == KS_URXVT_MOUSE
  # endif
! 	   )
  	{
! 	    /* Check for some responses from the terminal starting with
! 	     * "<Esc>[" or CSI:
  	     *
! 	     * - Xterm version string: <Esc>[>{x};{vers};{y}c
  	     *   Also eat other possible responses to t_RV, rxvt returns
  	     *   "<Esc>[?1;2c". Also accept CSI instead of <Esc>[.
  	     *   mrxvt has been reported to have "+" in the version. Assume
  	     *   the escape sequence ends with a letter or one of "{|}~".
  	     *
! 	     * - Cursor position report: <Esc>[{row};{col}R
! 	     *   The final byte must be 'R'. It is used for checking the
  	     *   ambiguous-width character state.
  	     */
  	    p = tp[0] == CSI ? tp + 1 : tp + 2;
***************
*** 4269,4304 ****
  		 * u7_status is not "sent", it may be from a previous Vim that
  		 * just exited.  But not for <S-F3>, it sends something
  		 * similar, check for row and column to make sense. */
! 		if (j == 1 && tp[i] == 'R' && row_char == '2' && col >= 2)
  		{
! 		    char *aw = NULL;
  
! 		    LOG_TR("Received U7 status");
! 		    u7_status = U7_GOT;
  # ifdef FEAT_AUTOCMD
! 		    did_cursorhold = TRUE;
  # endif
! 		    if (col == 2)
! 			aw = "single";
! 		    else if (col == 3)
! 			aw = "double";
! 		    if (aw != NULL && STRCMP(aw, p_ambw) != 0)
! 		    {
! 			/* Setting the option causes a screen redraw. Do that
! 			 * right away if possible, keeping any messages. */
! 			set_option_value((char_u *)"ambw", 0L, (char_u *)aw, 0);
! # ifdef DEBUG_TERMRESPONSE
  			{
! 			    char buf[100];
! 			    int  r = redraw_asap(CLEAR);
  
! 			    sprintf(buf, "set 'ambiwidth', redraw_asap(): %d",
! 									   r);
! 			    log_tr(buf);
! 			}
  # else
! 			redraw_asap(CLEAR);
  # endif
  		    }
  		    key_name[0] = (int)KS_EXTRA;
  		    key_name[1] = (int)KE_IGNORE;
--- 4234,4275 ----
  		 * u7_status is not "sent", it may be from a previous Vim that
  		 * just exited.  But not for <S-F3>, it sends something
  		 * similar, check for row and column to make sense. */
! 		if (j == 1 && tp[i] == 'R')
  		{
! 		    if (row_char == '2' && col >= 2)
! 		    {
! 			char *aw = NULL;
  
! 			LOG_TR("Received U7 status");
! 			u7_status = U7_GOT;
  # ifdef FEAT_AUTOCMD
! 			did_cursorhold = TRUE;
  # endif
! 			if (col == 2)
! 			    aw = "single";
! 			else if (col == 3)
! 			    aw = "double";
! 			if (aw != NULL && STRCMP(aw, p_ambw) != 0)
  			{
! 			    /* Setting the option causes a screen redraw. Do
! 			     * that right away if possible, keeping any
! 			     * messages. */
! 			    set_option_value((char_u *)"ambw", 0L,
! 					     (char_u *)aw, 0);
! # ifdef DEBUG_TERMRESPONSE
! 			    {
! 				char buf[100];
! 				int  r = redraw_asap(CLEAR);
  
! 				sprintf(buf,
! 					"set 'ambiwidth', redraw_asap(): %d",
! 					r);
! 				log_tr(buf);
! 			    }
  # else
! 			    redraw_asap(CLEAR);
  # endif
+ 			}
  		    }
  		    key_name[0] = (int)KS_EXTRA;
  		    key_name[1] = (int)KE_IGNORE;
***************
*** 4563,4581 ****
  			return -1;
  
  		    /* when mouse reporting is SGR, add 32 to mouse code */
!                     if (key_name[0] == KS_SGR_MOUSE)
!                         mouse_code += 32;
  
  		    mouse_col = getdigits(&p) - 1;
  		    if (*p++ != ';')
  			return -1;
  
  		    mouse_row = getdigits(&p) - 1;
!                     if (key_name[0] == KS_SGR_MOUSE && *p == 'm')
  			mouse_code |= MOUSE_RELEASE;
!                     else if (*p != 'M')
  			return -1;
!                     p++;
  
  		    slen += (int)(p - (tp + slen));
  
--- 4534,4552 ----
  			return -1;
  
  		    /* when mouse reporting is SGR, add 32 to mouse code */
! 		    if (key_name[0] == KS_SGR_MOUSE)
! 			mouse_code += 32;
  
  		    mouse_col = getdigits(&p) - 1;
  		    if (*p++ != ';')
  			return -1;
  
  		    mouse_row = getdigits(&p) - 1;
! 		    if (key_name[0] == KS_SGR_MOUSE && *p == 'm')
  			mouse_code |= MOUSE_RELEASE;
! 		    else if (*p != 'M')
  			return -1;
! 		    p++;
  
  		    slen += (int)(p - (tp + slen));
  
***************
*** 4592,4598 ****
  			for (slen2 = slen; slen2 < len; slen2++)
  			{
  			    if (tp[slen2] == 'M'
!                                 || (key_name[0] == KS_SGR_MOUSE
  							 && tp[slen2] == 'm'))
  			    {
  				cmd_complete = 1;
--- 4563,4569 ----
  			for (slen2 = slen; slen2 < len; slen2++)
  			{
  			    if (tp[slen2] == 'M'
! 				    || (key_name[0] == KS_SGR_MOUSE
  							 && tp[slen2] == 'm'))
  			    {
  				cmd_complete = 1;
***************
*** 5769,5774 ****
--- 5740,5748 ----
   * termcap codes from the terminal itself.
   * We get them one by one to avoid a very long response string.
   */
+ static int xt_index_in = 0;
+ static int xt_index_out = 0;
+ 
      static void
  req_codes_from_term()
  {
*** ../vim-7.4.388/src/proto/term.pro	2014-07-09 19:13:45.007701718 +0200
--- src/proto/term.pro	2014-07-30 17:04:40.791525930 +0200
***************
*** 34,41 ****
  void settmode __ARGS((int tmode));
  void starttermcap __ARGS((void));
  void stoptermcap __ARGS((void));
- int did_request_esc_sequence __ARGS((void));
- void resume_get_esc_sequence __ARGS((void));
  void may_req_termresponse __ARGS((void));
  void may_req_ambiguous_char_width __ARGS((void));
  int swapping_screen __ARGS((void));
--- 34,39 ----
*** ../vim-7.4.388/src/version.c	2014-07-30 16:44:17.503534723 +0200
--- src/version.c	2014-07-30 17:03:13.715526556 +0200
***************
*** 736,737 ****
--- 736,739 ----
  {   /* Add new patch number below this line */
+ /**/
+     389,
  /**/

-- 
The only way the average employee can speak to an executive is by taking a
second job as a golf caddie.
				(Scott Adams - The Dilbert principle)

 /// 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    ///