3ef2ca
To: vim_dev@googlegroups.com
3ef2ca
Subject: Patch 7.4.305
3ef2ca
Fcc: outbox
3ef2ca
From: Bram Moolenaar <Bram@moolenaar.net>
3ef2ca
Mime-Version: 1.0
3ef2ca
Content-Type: text/plain; charset=UTF-8
3ef2ca
Content-Transfer-Encoding: 8bit
3ef2ca
------------
3ef2ca
3ef2ca
Patch 7.4.305
3ef2ca
Problem:    Making 'ttymouse' empty after the xterm version was requested
3ef2ca
	    causes problems. (Elijah Griffin)
3ef2ca
Solution:   Do not check for DEC mouse sequences when the xterm version was
3ef2ca
	    requested.  Also don't request the xterm version when DEC mouse
3ef2ca
	    was enabled.
3ef2ca
Files:	    src/term.c, src/os_unix.c, src/proto/term.pro, src/globals.h
3ef2ca
3ef2ca
3ef2ca
*** ../vim-7.4.304/src/term.c	2014-03-25 13:46:22.841832960 +0100
3ef2ca
--- src/term.c	2014-05-22 17:12:59.198299628 +0200
3ef2ca
***************
3ef2ca
*** 153,158 ****
3ef2ca
--- 153,163 ----
3ef2ca
  static char_u *vim_tgetstr __ARGS((char *s, char_u **pp));
3ef2ca
  #endif /* HAVE_TGETENT */
3ef2ca
  
3ef2ca
+ #if defined(FEAT_TERMRESPONSE)
3ef2ca
+ static int xt_index_in = 0;
3ef2ca
+ static int xt_index_out = 0;
3ef2ca
+ #endif
3ef2ca
+ 
3ef2ca
  static int  detected_8bit = FALSE;	/* detected 8-bit terminal */
3ef2ca
  
3ef2ca
  static struct builtin_term builtin_termcaps[] =
3ef2ca
***************
3ef2ca
*** 3259,3265 ****
3ef2ca
  	    may_req_termresponse();
3ef2ca
  	    /* Immediately check for a response.  If t_Co changes, we don't
3ef2ca
  	     * want to redraw with wrong colors first. */
3ef2ca
! 	    if (crv_status != CRV_GET)
3ef2ca
  		check_for_codes_from_term();
3ef2ca
  	}
3ef2ca
  #endif
3ef2ca
--- 3264,3270 ----
3ef2ca
  	    may_req_termresponse();
3ef2ca
  	    /* Immediately check for a response.  If t_Co changes, we don't
3ef2ca
  	     * want to redraw with wrong colors first. */
3ef2ca
! 	    if (crv_status == CRV_SENT)
3ef2ca
  		check_for_codes_from_term();
3ef2ca
  	}
3ef2ca
  #endif
3ef2ca
***************
3ef2ca
*** 3306,3311 ****
3ef2ca
--- 3311,3340 ----
3ef2ca
      }
3ef2ca
  }
3ef2ca
  
3ef2ca
+ #if defined(UNIX) || defined(PROTO)
3ef2ca
+ /*
3ef2ca
+  * Return TRUE when the xterm version was requested or anything else that
3ef2ca
+  * would send an ESC sequence back to Vim.
3ef2ca
+  * If not sent yet, prevent it from being sent soon.
3ef2ca
+  * Used to check whether it is OK to enable checking for DEC mouse codes,
3ef2ca
+  * which conflict with may xterm ESC sequences.
3ef2ca
+  */
3ef2ca
+     int
3ef2ca
+ did_request_esc_sequence()
3ef2ca
+ {
3ef2ca
+     if (crv_status == CRV_GET)
3ef2ca
+ 	crv_status = 0;
3ef2ca
+     if (u7_status == U7_GET)
3ef2ca
+ 	u7_status = 0;
3ef2ca
+     return crv_status == CRV_SENT || u7_status == U7_SENT
3ef2ca
+ # if defined(FEAT_TERMRESPONSE)
3ef2ca
+ 	|| xt_index_out > xt_index_in
3ef2ca
+ # endif
3ef2ca
+ 	;
3ef2ca
+ }
3ef2ca
+ #endif
3ef2ca
+ 
3ef2ca
+ 
3ef2ca
  #if defined(FEAT_TERMRESPONSE) || defined(PROTO)
3ef2ca
  /*
3ef2ca
   * Request version string (for xterm) when needed.
3ef2ca
***************
3ef2ca
*** 3319,3324 ****
3ef2ca
--- 3348,3355 ----
3ef2ca
   * Insert mode.
3ef2ca
   * On Unix only do it when both output and input are a tty (avoid writing
3ef2ca
   * request to terminal while reading from a file).
3ef2ca
+  * Do not do this when a mouse is being detected that starts with the same ESC
3ef2ca
+  * sequence as the termresponse.
3ef2ca
   * The result is caught in check_termcode().
3ef2ca
   */
3ef2ca
      void
3ef2ca
***************
3ef2ca
*** 3332,3337 ****
3ef2ca
--- 3363,3369 ----
3ef2ca
  # ifdef UNIX
3ef2ca
  	    && isatty(1)
3ef2ca
  	    && isatty(read_cmd_fd)
3ef2ca
+ 	    && !xterm_conflict_mouse
3ef2ca
  # endif
3ef2ca
  	    && *T_CRV != NUL)
3ef2ca
      {
3ef2ca
***************
3ef2ca
*** 5714,5722 ****
3ef2ca
   * termcap codes from the terminal itself.
3ef2ca
   * We get them one by one to avoid a very long response string.
3ef2ca
   */
3ef2ca
- static int xt_index_in = 0;
3ef2ca
- static int xt_index_out = 0;
3ef2ca
- 
3ef2ca
      static void
3ef2ca
  req_codes_from_term()
3ef2ca
  {
3ef2ca
--- 5746,5751 ----
3ef2ca
*** ../vim-7.4.304/src/os_unix.c	2014-05-13 20:19:53.573808877 +0200
3ef2ca
--- src/os_unix.c	2014-05-22 17:11:10.274301842 +0200
3ef2ca
***************
3ef2ca
*** 3667,3672 ****
3ef2ca
--- 3667,3674 ----
3ef2ca
      void
3ef2ca
  check_mouse_termcode()
3ef2ca
  {
3ef2ca
+     xterm_conflict_mouse = FALSE;
3ef2ca
+ 
3ef2ca
  # ifdef FEAT_MOUSE_XTERM
3ef2ca
      if (use_xterm_mouse()
3ef2ca
  # ifdef FEAT_MOUSE_URXVT
3ef2ca
***************
3ef2ca
*** 3711,3717 ****
3ef2ca
  # endif
3ef2ca
  
3ef2ca
  # ifdef FEAT_MOUSE_JSB
3ef2ca
!     /* conflicts with xterm mouse: "\033[" and "\033[M" ??? */
3ef2ca
      if (!use_xterm_mouse()
3ef2ca
  #  ifdef FEAT_GUI
3ef2ca
  	    && !gui.in_use
3ef2ca
--- 3713,3719 ----
3ef2ca
  # endif
3ef2ca
  
3ef2ca
  # ifdef FEAT_MOUSE_JSB
3ef2ca
!     /* There is no conflict, but it was disabled for xterm before. */
3ef2ca
      if (!use_xterm_mouse()
3ef2ca
  #  ifdef FEAT_GUI
3ef2ca
  	    && !gui.in_use
3ef2ca
***************
3ef2ca
*** 3738,3769 ****
3ef2ca
  # endif
3ef2ca
  
3ef2ca
  # ifdef FEAT_MOUSE_DEC
3ef2ca
!     /* conflicts with xterm mouse: "\033[" and "\033[M" */
3ef2ca
!     if (!use_xterm_mouse()
3ef2ca
  #  ifdef FEAT_GUI
3ef2ca
  	    && !gui.in_use
3ef2ca
  #  endif
3ef2ca
  	    )
3ef2ca
  	set_mouse_termcode(KS_DEC_MOUSE, (char_u *)(term_is_8bit(T_NAME)
3ef2ca
  		     ? IF_EB("\233", CSI_STR) : IF_EB("\033[", ESC_STR "[")));
3ef2ca
      else
3ef2ca
  	del_mouse_termcode(KS_DEC_MOUSE);
3ef2ca
  # endif
3ef2ca
  # ifdef FEAT_MOUSE_PTERM
3ef2ca
      /* same as the dec mouse */
3ef2ca
!     if (!use_xterm_mouse()
3ef2ca
  #  ifdef FEAT_GUI
3ef2ca
  	    && !gui.in_use
3ef2ca
  #  endif
3ef2ca
  	    )
3ef2ca
  	set_mouse_termcode(KS_PTERM_MOUSE,
3ef2ca
  				      (char_u *) IF_EB("\033[", ESC_STR "["));
3ef2ca
      else
3ef2ca
  	del_mouse_termcode(KS_PTERM_MOUSE);
3ef2ca
  # endif
3ef2ca
  # ifdef FEAT_MOUSE_URXVT
3ef2ca
      /* same as the dec mouse */
3ef2ca
!     if (use_xterm_mouse() == 3
3ef2ca
  #  ifdef FEAT_GUI
3ef2ca
  	    && !gui.in_use
3ef2ca
  #  endif
3ef2ca
--- 3740,3779 ----
3ef2ca
  # endif
3ef2ca
  
3ef2ca
  # ifdef FEAT_MOUSE_DEC
3ef2ca
!     /* Conflicts with xterm mouse: "\033[" and "\033[M".
3ef2ca
!      * Also conflicts with the xterm termresponse, skip this if it was
3ef2ca
!      * requested already. */
3ef2ca
!     if (!use_xterm_mouse() && !did_request_esc_sequence()
3ef2ca
  #  ifdef FEAT_GUI
3ef2ca
  	    && !gui.in_use
3ef2ca
  #  endif
3ef2ca
  	    )
3ef2ca
+     {
3ef2ca
  	set_mouse_termcode(KS_DEC_MOUSE, (char_u *)(term_is_8bit(T_NAME)
3ef2ca
  		     ? IF_EB("\233", CSI_STR) : IF_EB("\033[", ESC_STR "[")));
3ef2ca
+ 	xterm_conflict_mouse = TRUE;
3ef2ca
+     }
3ef2ca
      else
3ef2ca
  	del_mouse_termcode(KS_DEC_MOUSE);
3ef2ca
  # endif
3ef2ca
  # ifdef FEAT_MOUSE_PTERM
3ef2ca
      /* same as the dec mouse */
3ef2ca
!     if (!use_xterm_mouse() && !did_request_esc_sequence()
3ef2ca
  #  ifdef FEAT_GUI
3ef2ca
  	    && !gui.in_use
3ef2ca
  #  endif
3ef2ca
  	    )
3ef2ca
+     {
3ef2ca
  	set_mouse_termcode(KS_PTERM_MOUSE,
3ef2ca
  				      (char_u *) IF_EB("\033[", ESC_STR "["));
3ef2ca
+ 	xterm_conflict_mouse = TRUE;
3ef2ca
+     }
3ef2ca
      else
3ef2ca
  	del_mouse_termcode(KS_PTERM_MOUSE);
3ef2ca
  # endif
3ef2ca
  # ifdef FEAT_MOUSE_URXVT
3ef2ca
      /* same as the dec mouse */
3ef2ca
!     if (use_xterm_mouse() == 3 && !did_request_esc_sequence()
3ef2ca
  #  ifdef FEAT_GUI
3ef2ca
  	    && !gui.in_use
3ef2ca
  #  endif
3ef2ca
***************
3ef2ca
*** 3778,3783 ****
3ef2ca
--- 3788,3794 ----
3ef2ca
  	    mch_setmouse(FALSE);
3ef2ca
  	    setmouse();
3ef2ca
  	}
3ef2ca
+ 	xterm_conflict_mouse = TRUE;
3ef2ca
      }
3ef2ca
      else
3ef2ca
  	del_mouse_termcode(KS_URXVT_MOUSE);
3ef2ca
*** ../vim-7.4.304/src/proto/term.pro	2013-09-29 16:27:42.000000000 +0200
3ef2ca
--- src/proto/term.pro	2014-05-22 16:58:25.806317380 +0200
3ef2ca
***************
3ef2ca
*** 34,39 ****
3ef2ca
--- 34,40 ----
3ef2ca
  void settmode __ARGS((int tmode));
3ef2ca
  void starttermcap __ARGS((void));
3ef2ca
  void stoptermcap __ARGS((void));
3ef2ca
+ int did_request_esc_sequence __ARGS((void));
3ef2ca
  void may_req_termresponse __ARGS((void));
3ef2ca
  void may_req_ambiguous_char_width __ARGS((void));
3ef2ca
  int swapping_screen __ARGS((void));
3ef2ca
*** ../vim-7.4.304/src/globals.h	2014-04-06 20:45:40.123357453 +0200
3ef2ca
--- src/globals.h	2014-05-22 17:07:39.130306133 +0200
3ef2ca
***************
3ef2ca
*** 1333,1338 ****
3ef2ca
--- 1333,1341 ----
3ef2ca
  #if defined(UNIX) || defined(VMS)
3ef2ca
  EXTERN int	term_is_xterm INIT(= FALSE);	/* xterm-like 'term' */
3ef2ca
  #endif
3ef2ca
+ #if defined(UNIX)
3ef2ca
+ EXTERN int	xterm_conflict_mouse INIT(= FALSE);
3ef2ca
+ #endif
3ef2ca
  
3ef2ca
  #ifdef BACKSLASH_IN_FILENAME
3ef2ca
  EXTERN char	psepc INIT(= '\\');	/* normal path separator character */
3ef2ca
*** ../vim-7.4.304/src/version.c	2014-05-22 16:29:03.378353200 +0200
3ef2ca
--- src/version.c	2014-05-22 16:58:16.150317576 +0200
3ef2ca
***************
3ef2ca
*** 736,737 ****
3ef2ca
--- 736,739 ----
3ef2ca
  {   /* Add new patch number below this line */
3ef2ca
+ /**/
3ef2ca
+     305,
3ef2ca
  /**/
3ef2ca
3ef2ca
-- 
3ef2ca
hundred-and-one symptoms of being an internet addict:
3ef2ca
195. Your cat has its own home page.
3ef2ca
3ef2ca
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
3ef2ca
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
3ef2ca
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
3ef2ca
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///