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