Blame SOURCES/7.4.389

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