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