Karsten Hopp 76628d
To: vim_dev@googlegroups.com
Karsten Hopp 76628d
Subject: Patch 7.3.632
Karsten Hopp 76628d
Fcc: outbox
Karsten Hopp 76628d
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 76628d
Mime-Version: 1.0
Karsten Hopp 76628d
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 76628d
Content-Transfer-Encoding: 8bit
Karsten Hopp 76628d
------------
Karsten Hopp 76628d
Karsten Hopp 76628d
Patch 7.3.632
Karsten Hopp 76628d
Problem:    Cannot select beyond 222 columns with the mouse in xterm.
Karsten Hopp 76628d
Solution:   Add support for SGR mouse tracking. (Hayaki Saito)
Karsten Hopp 76628d
Files:      runtime/doc/options.txt, src/feature.h, src/keymap.h, src/misc2.c,
Karsten Hopp 76628d
            src/option.h, src/os_unix.c, src/term.c, src/version.c
Karsten Hopp 76628d
Karsten Hopp 76628d
Karsten Hopp 76628d
*** ../vim-7.3.631/runtime/doc/options.txt	2012-07-10 16:49:08.000000000 +0200
Karsten Hopp 76628d
--- runtime/doc/options.txt	2012-08-15 16:04:26.000000000 +0200
Karsten Hopp 76628d
***************
Karsten Hopp 76628d
*** 7383,7388 ****
Karsten Hopp 76628d
--- 7424,7435 ----
Karsten Hopp 76628d
  	   jsbterm	JSB term mouse handling.
Karsten Hopp 76628d
  							*pterm-mouse*
Karsten Hopp 76628d
  	   pterm	QNX pterm mouse handling.
Karsten Hopp 76628d
+ 							*urxvt-mouse*
Karsten Hopp 76628d
+ 	   urxvt	Mouse handling for the urxvt (rxvt-unicode) terminal.
Karsten Hopp 76628d
+ 							*sgr-mouse*
Karsten Hopp 76628d
+ 	   sgr		Mouse handling for the terminal that emits SGR-styled
Karsten Hopp 76628d
+ 			mouse reporting. Works with xterm version 277 or
Karsten Hopp 76628d
+ 			later.
Karsten Hopp 76628d
  
Karsten Hopp 76628d
  	The mouse handling must be enabled at compile time |+mouse_xterm|
Karsten Hopp 76628d
  	|+mouse_dec| |+mouse_netterm|.
Karsten Hopp 76628d
***************
Karsten Hopp 76628d
*** 7395,7400 ****
Karsten Hopp 76628d
--- 7442,7448 ----
Karsten Hopp 76628d
  	or "xterm2" already.  The main use of this option is to set it to
Karsten Hopp 76628d
  	"xterm", when the terminal name doesn't start with "xterm", but it can
Karsten Hopp 76628d
  	handle xterm mouse codes.
Karsten Hopp 76628d
+ 	The "sgr" value will be set if the xterm version is 277 or later.
Karsten Hopp 76628d
  	The "xterm2" value will be set if the xterm version is reported to be
Karsten Hopp 76628d
  	95 or higher.  This only works when compiled with the |+termresponse|
Karsten Hopp 76628d
  	feature and if |t_RV| is set to the escape sequence to request the
Karsten Hopp 76628d
*** ../vim-7.3.631/src/feature.h	2012-04-25 16:50:44.000000000 +0200
Karsten Hopp 76628d
--- src/feature.h	2012-08-15 15:46:07.000000000 +0200
Karsten Hopp 76628d
***************
Karsten Hopp 76628d
*** 1056,1061 ****
Karsten Hopp 76628d
--- 1056,1064 ----
Karsten Hopp 76628d
  # ifdef FEAT_BIG
Karsten Hopp 76628d
  #  define FEAT_MOUSE_URXVT
Karsten Hopp 76628d
  # endif
Karsten Hopp 76628d
+ # ifdef FEAT_BIG
Karsten Hopp 76628d
+ #  define FEAT_MOUSE_SGR
Karsten Hopp 76628d
+ # endif
Karsten Hopp 76628d
  # if defined(FEAT_NORMAL) && (defined(MSDOS) || defined(WIN3264))
Karsten Hopp 76628d
  #  define DOS_MOUSE
Karsten Hopp 76628d
  # endif
Karsten Hopp 76628d
***************
Karsten Hopp 76628d
*** 1077,1082 ****
Karsten Hopp 76628d
--- 1080,1090 ----
Karsten Hopp 76628d
  # define FEAT_MOUSE_XTERM
Karsten Hopp 76628d
  #endif
Karsten Hopp 76628d
  
Karsten Hopp 76628d
+ /* sgr is a small variation of mouse_xterm, and shares its code */
Karsten Hopp 76628d
+ #if defined(FEAT_MOUSE_SGR) && !defined(FEAT_MOUSE_XTERM)
Karsten Hopp 76628d
+ # define FEAT_MOUSE_XTERM
Karsten Hopp 76628d
+ #endif
Karsten Hopp 76628d
+ 
Karsten Hopp 76628d
  /* Define FEAT_MOUSE when any of the above is defined or FEAT_GUI. */
Karsten Hopp 76628d
  #if !defined(FEAT_MOUSE_TTY) \
Karsten Hopp 76628d
  	&& (defined(FEAT_MOUSE_XTERM) \
Karsten Hopp 76628d
***************
Karsten Hopp 76628d
*** 1087,1093 ****
Karsten Hopp 76628d
  	    || defined(FEAT_MOUSE_JSB) \
Karsten Hopp 76628d
  	    || defined(FEAT_MOUSE_PTERM) \
Karsten Hopp 76628d
  	    || defined(FEAT_SYSMOUSE) \
Karsten Hopp 76628d
! 	    || defined(FEAT_MOUSE_URXVT))
Karsten Hopp 76628d
  # define FEAT_MOUSE_TTY		/* include non-GUI mouse support */
Karsten Hopp 76628d
  #endif
Karsten Hopp 76628d
  #if !defined(FEAT_MOUSE) && (defined(FEAT_MOUSE_TTY) || defined(FEAT_GUI))
Karsten Hopp 76628d
--- 1095,1102 ----
Karsten Hopp 76628d
  	    || defined(FEAT_MOUSE_JSB) \
Karsten Hopp 76628d
  	    || defined(FEAT_MOUSE_PTERM) \
Karsten Hopp 76628d
  	    || defined(FEAT_SYSMOUSE) \
Karsten Hopp 76628d
! 	    || defined(FEAT_MOUSE_URXVT) \
Karsten Hopp 76628d
! 	    || defined(FEAT_MOUSE_SGR))
Karsten Hopp 76628d
  # define FEAT_MOUSE_TTY		/* include non-GUI mouse support */
Karsten Hopp 76628d
  #endif
Karsten Hopp 76628d
  #if !defined(FEAT_MOUSE) && (defined(FEAT_MOUSE_TTY) || defined(FEAT_GUI))
Karsten Hopp 76628d
*** ../vim-7.3.631/src/keymap.h	2012-01-20 17:15:47.000000000 +0100
Karsten Hopp 76628d
--- src/keymap.h	2012-08-15 15:46:07.000000000 +0200
Karsten Hopp 76628d
***************
Karsten Hopp 76628d
*** 110,115 ****
Karsten Hopp 76628d
--- 110,118 ----
Karsten Hopp 76628d
  /* Used for the urxvt mouse. */
Karsten Hopp 76628d
  #define KS_URXVT_MOUSE		238
Karsten Hopp 76628d
  
Karsten Hopp 76628d
+ /* Used for the sgr mouse. */
Karsten Hopp 76628d
+ #define KS_SGR_MOUSE		237
Karsten Hopp 76628d
+ 
Karsten Hopp 76628d
  /*
Karsten Hopp 76628d
   * Filler used after KS_SPECIAL and others
Karsten Hopp 76628d
   */
Karsten Hopp 76628d
***************
Karsten Hopp 76628d
*** 412,417 ****
Karsten Hopp 76628d
--- 415,421 ----
Karsten Hopp 76628d
  #define K_JSBTERM_MOUSE	TERMCAP2KEY(KS_JSBTERM_MOUSE, KE_FILLER)
Karsten Hopp 76628d
  #define K_PTERM_MOUSE	TERMCAP2KEY(KS_PTERM_MOUSE, KE_FILLER)
Karsten Hopp 76628d
  #define K_URXVT_MOUSE	TERMCAP2KEY(KS_URXVT_MOUSE, KE_FILLER)
Karsten Hopp 76628d
+ #define K_SGR_MOUSE	TERMCAP2KEY(KS_SGR_MOUSE, KE_FILLER)
Karsten Hopp 76628d
  
Karsten Hopp 76628d
  #define K_SELECT	TERMCAP2KEY(KS_SELECT, KE_FILLER)
Karsten Hopp 76628d
  #define K_TEAROFF	TERMCAP2KEY(KS_TEAROFF, KE_FILLER)
Karsten Hopp 76628d
*** ../vim-7.3.631/src/misc2.c	2012-08-15 14:04:50.000000000 +0200
Karsten Hopp 76628d
--- src/misc2.c	2012-08-15 15:46:07.000000000 +0200
Karsten Hopp 76628d
***************
Karsten Hopp 76628d
*** 2433,2438 ****
Karsten Hopp 76628d
--- 2433,2441 ----
Karsten Hopp 76628d
  #ifdef FEAT_MOUSE_URXVT
Karsten Hopp 76628d
      {K_URXVT_MOUSE,	(char_u *)"UrxvtMouse"},
Karsten Hopp 76628d
  #endif
Karsten Hopp 76628d
+ #ifdef FEAT_MOUSE_SGR
Karsten Hopp 76628d
+     {K_SGR_MOUSE,	(char_u *)"SgrMouse"},
Karsten Hopp 76628d
+ #endif
Karsten Hopp 76628d
      {K_LEFTMOUSE,	(char_u *)"LeftMouse"},
Karsten Hopp 76628d
      {K_LEFTMOUSE_NM,	(char_u *)"LeftMouseNM"},
Karsten Hopp 76628d
      {K_LEFTDRAG,	(char_u *)"LeftDrag"},
Karsten Hopp 76628d
*** ../vim-7.3.631/src/option.h	2012-07-10 16:49:08.000000000 +0200
Karsten Hopp 76628d
--- src/option.h	2012-08-15 15:46:07.000000000 +0200
Karsten Hopp 76628d
***************
Karsten Hopp 76628d
*** 822,828 ****
Karsten Hopp 76628d
  EXTERN char_u	*p_ttym;	/* 'ttymouse' */
Karsten Hopp 76628d
  EXTERN unsigned ttym_flags;
Karsten Hopp 76628d
  # ifdef IN_OPTION_C
Karsten Hopp 76628d
! static char *(p_ttym_values[]) = {"xterm", "xterm2", "dec", "netterm", "jsbterm", "pterm", "urxvt", NULL};
Karsten Hopp 76628d
  # endif
Karsten Hopp 76628d
  # define TTYM_XTERM		0x01
Karsten Hopp 76628d
  # define TTYM_XTERM2		0x02
Karsten Hopp 76628d
--- 822,828 ----
Karsten Hopp 76628d
  EXTERN char_u	*p_ttym;	/* 'ttymouse' */
Karsten Hopp 76628d
  EXTERN unsigned ttym_flags;
Karsten Hopp 76628d
  # ifdef IN_OPTION_C
Karsten Hopp 76628d
! static char *(p_ttym_values[]) = {"xterm", "xterm2", "dec", "netterm", "jsbterm", "pterm", "urxvt", "sgr", NULL};
Karsten Hopp 76628d
  # endif
Karsten Hopp 76628d
  # define TTYM_XTERM		0x01
Karsten Hopp 76628d
  # define TTYM_XTERM2		0x02
Karsten Hopp 76628d
***************
Karsten Hopp 76628d
*** 831,836 ****
Karsten Hopp 76628d
--- 831,837 ----
Karsten Hopp 76628d
  # define TTYM_JSBTERM		0x10
Karsten Hopp 76628d
  # define TTYM_PTERM		0x20
Karsten Hopp 76628d
  # define TTYM_URXVT		0x40
Karsten Hopp 76628d
+ # define TTYM_SGR		0x80
Karsten Hopp 76628d
  #endif
Karsten Hopp 76628d
  EXTERN char_u	*p_udir;	/* 'undodir' */
Karsten Hopp 76628d
  EXTERN long	p_ul;		/* 'undolevels' */
Karsten Hopp 76628d
*** ../vim-7.3.631/src/os_unix.c	2012-04-20 15:55:10.000000000 +0200
Karsten Hopp 76628d
--- src/os_unix.c	2012-08-15 16:06:54.000000000 +0200
Karsten Hopp 76628d
***************
Karsten Hopp 76628d
*** 2159,2168 ****
Karsten Hopp 76628d
--- 2159,2171 ----
Karsten Hopp 76628d
   * Return 1 for "xterm".
Karsten Hopp 76628d
   * Return 2 for "xterm2".
Karsten Hopp 76628d
   * Return 3 for "urxvt".
Karsten Hopp 76628d
+  * Return 4 for "sgr".
Karsten Hopp 76628d
   */
Karsten Hopp 76628d
      int
Karsten Hopp 76628d
  use_xterm_mouse()
Karsten Hopp 76628d
  {
Karsten Hopp 76628d
+     if (ttym_flags == TTYM_SGR)
Karsten Hopp 76628d
+ 	return 4;
Karsten Hopp 76628d
      if (ttym_flags == TTYM_URXVT)
Karsten Hopp 76628d
  	return 3;
Karsten Hopp 76628d
      if (ttym_flags == TTYM_XTERM2)
Karsten Hopp 76628d
***************
Karsten Hopp 76628d
*** 3339,3345 ****
Karsten Hopp 76628d
      xterm_mouse_vers = use_xterm_mouse();
Karsten Hopp 76628d
  
Karsten Hopp 76628d
  # ifdef FEAT_MOUSE_URXVT
Karsten Hopp 76628d
!     if (ttym_flags == TTYM_URXVT) {
Karsten Hopp 76628d
  	out_str_nf((char_u *)
Karsten Hopp 76628d
  		   (on
Karsten Hopp 76628d
  		   ? IF_EB("\033[?1015h", ESC_STR "[?1015h")
Karsten Hopp 76628d
--- 3342,3349 ----
Karsten Hopp 76628d
      xterm_mouse_vers = use_xterm_mouse();
Karsten Hopp 76628d
  
Karsten Hopp 76628d
  # ifdef FEAT_MOUSE_URXVT
Karsten Hopp 76628d
!     if (ttym_flags == TTYM_URXVT)
Karsten Hopp 76628d
!     {
Karsten Hopp 76628d
  	out_str_nf((char_u *)
Karsten Hopp 76628d
  		   (on
Karsten Hopp 76628d
  		   ? IF_EB("\033[?1015h", ESC_STR "[?1015h")
Karsten Hopp 76628d
***************
Karsten Hopp 76628d
*** 3348,3353 ****
Karsten Hopp 76628d
--- 3352,3368 ----
Karsten Hopp 76628d
      }
Karsten Hopp 76628d
  # endif
Karsten Hopp 76628d
  
Karsten Hopp 76628d
+ # ifdef FEAT_MOUSE_SGR
Karsten Hopp 76628d
+     if (ttym_flags == TTYM_SGR)
Karsten Hopp 76628d
+     {
Karsten Hopp 76628d
+ 	out_str_nf((char_u *)
Karsten Hopp 76628d
+ 		   (on
Karsten Hopp 76628d
+ 		   ? IF_EB("\033[?1006h", ESC_STR "[?1006h")
Karsten Hopp 76628d
+ 		   : IF_EB("\033[?1006l", ESC_STR "[?1006l")));
Karsten Hopp 76628d
+ 	ison = on;
Karsten Hopp 76628d
+     }
Karsten Hopp 76628d
+ # endif
Karsten Hopp 76628d
+ 
Karsten Hopp 76628d
      if (xterm_mouse_vers > 0)
Karsten Hopp 76628d
      {
Karsten Hopp 76628d
  	if (on)	/* enable mouse events, use mouse tracking if available */
Karsten Hopp 76628d
***************
Karsten Hopp 76628d
*** 3577,3582 ****
Karsten Hopp 76628d
--- 3592,3618 ----
Karsten Hopp 76628d
      else
Karsten Hopp 76628d
  	del_mouse_termcode(KS_URXVT_MOUSE);
Karsten Hopp 76628d
  # endif
Karsten Hopp 76628d
+ # ifdef FEAT_MOUSE_SGR
Karsten Hopp 76628d
+     /* same as the dec mouse */
Karsten Hopp 76628d
+     if (use_xterm_mouse() == 4
Karsten Hopp 76628d
+ #  ifdef FEAT_GUI
Karsten Hopp 76628d
+ 	    && !gui.in_use
Karsten Hopp 76628d
+ #  endif
Karsten Hopp 76628d
+ 	    )
Karsten Hopp 76628d
+     {
Karsten Hopp 76628d
+ 	set_mouse_termcode(KS_SGR_MOUSE, (char_u *)(term_is_8bit(T_NAME)
Karsten Hopp 76628d
+ 		    ? IF_EB("\233<", CSI_STR "<")
Karsten Hopp 76628d
+ 		    : IF_EB("\033[<", ESC_STR "[<")));
Karsten Hopp 76628d
+ 
Karsten Hopp 76628d
+ 	if (*p_mouse != NUL)
Karsten Hopp 76628d
+ 	{
Karsten Hopp 76628d
+ 	    mch_setmouse(FALSE);
Karsten Hopp 76628d
+ 	    setmouse();
Karsten Hopp 76628d
+ 	}
Karsten Hopp 76628d
+     }
Karsten Hopp 76628d
+     else
Karsten Hopp 76628d
+ 	del_mouse_termcode(KS_SGR_MOUSE);
Karsten Hopp 76628d
+ # endif
Karsten Hopp 76628d
  }
Karsten Hopp 76628d
  #endif
Karsten Hopp 76628d
  
Karsten Hopp 76628d
*** ../vim-7.3.631/src/term.c	2012-02-05 22:05:44.000000000 +0100
Karsten Hopp 76628d
--- src/term.c	2012-08-15 16:14:09.000000000 +0200
Karsten Hopp 76628d
***************
Karsten Hopp 76628d
*** 1997,2002 ****
Karsten Hopp 76628d
--- 1997,2003 ----
Karsten Hopp 76628d
  #  define HMT_JSBTERM	8
Karsten Hopp 76628d
  #  define HMT_PTERM	16
Karsten Hopp 76628d
  #  define HMT_URXVT	32
Karsten Hopp 76628d
+ #  define HMT_SGR	64
Karsten Hopp 76628d
  static int has_mouse_termcode = 0;
Karsten Hopp 76628d
  # endif
Karsten Hopp 76628d
  
Karsten Hopp 76628d
***************
Karsten Hopp 76628d
*** 2037,2042 ****
Karsten Hopp 76628d
--- 2038,2048 ----
Karsten Hopp 76628d
  	has_mouse_termcode |= HMT_URXVT;
Karsten Hopp 76628d
      else
Karsten Hopp 76628d
  #   endif
Karsten Hopp 76628d
+ #   ifdef FEAT_MOUSE_SGR
Karsten Hopp 76628d
+     if (n == KS_SGR_MOUSE)
Karsten Hopp 76628d
+ 	has_mouse_termcode |= HMT_SGR;
Karsten Hopp 76628d
+     else
Karsten Hopp 76628d
+ #   endif
Karsten Hopp 76628d
  	has_mouse_termcode |= HMT_NORMAL;
Karsten Hopp 76628d
  #  endif
Karsten Hopp 76628d
  }
Karsten Hopp 76628d
***************
Karsten Hopp 76628d
*** 2079,2084 ****
Karsten Hopp 76628d
--- 2085,2095 ----
Karsten Hopp 76628d
  	has_mouse_termcode &= ~HMT_URXVT;
Karsten Hopp 76628d
      else
Karsten Hopp 76628d
  #   endif
Karsten Hopp 76628d
+ #   ifdef FEAT_MOUSE_SGR
Karsten Hopp 76628d
+     if (n == KS_SGR_MOUSE)
Karsten Hopp 76628d
+ 	has_mouse_termcode &= ~HMT_SGR;
Karsten Hopp 76628d
+     else
Karsten Hopp 76628d
+ #   endif
Karsten Hopp 76628d
  	has_mouse_termcode &= ~HMT_NORMAL;
Karsten Hopp 76628d
  #  endif
Karsten Hopp 76628d
  }
Karsten Hopp 76628d
***************
Karsten Hopp 76628d
*** 4023,4029 ****
Karsten Hopp 76628d
  #ifdef FEAT_TERMRESPONSE
Karsten Hopp 76628d
  	if (key_name[0] == NUL
Karsten Hopp 76628d
  	    /* URXVT mouse uses <ESC>[#;#;#M, but we are matching <ESC>[ */
Karsten Hopp 76628d
! 	    || key_name[0] == KS_URXVT_MOUSE)
Karsten Hopp 76628d
  	{
Karsten Hopp 76628d
  	    /* Check for xterm version string: "<Esc>[>{x};{vers};{y}c".  Also
Karsten Hopp 76628d
  	     * eat other possible responses to t_RV, rxvt returns
Karsten Hopp 76628d
--- 4034,4041 ----
Karsten Hopp 76628d
  #ifdef FEAT_TERMRESPONSE
Karsten Hopp 76628d
  	if (key_name[0] == NUL
Karsten Hopp 76628d
  	    /* URXVT mouse uses <ESC>[#;#;#M, but we are matching <ESC>[ */
Karsten Hopp 76628d
! 	    || key_name[0] == KS_URXVT_MOUSE
Karsten Hopp 76628d
! 	    || key_name[0] == KS_SGR_MOUSE)
Karsten Hopp 76628d
  	{
Karsten Hopp 76628d
  	    /* Check for xterm version string: "<Esc>[>{x};{vers};{y}c".  Also
Karsten Hopp 76628d
  	     * eat other possible responses to t_RV, rxvt returns
Karsten Hopp 76628d
***************
Karsten Hopp 76628d
*** 4061,4066 ****
Karsten Hopp 76628d
--- 4073,4088 ----
Karsten Hopp 76628d
  
Karsten Hopp 76628d
  		    if (tp[1 + (tp[0] != CSI)] == '>' && j == 2)
Karsten Hopp 76628d
  		    {
Karsten Hopp 76628d
+ # ifdef TTYM_SGR
Karsten Hopp 76628d
+ 			if (extra >= 277
Karsten Hopp 76628d
+ # ifdef TTYM_URXVT
Karsten Hopp 76628d
+ 				&& ttym_flags != TTYM_URXVT
Karsten Hopp 76628d
+ # endif
Karsten Hopp 76628d
+ 				)
Karsten Hopp 76628d
+ 			    set_option_value((char_u *)"ttym", 0L,
Karsten Hopp 76628d
+ 							  (char_u *)"sgr", 0);
Karsten Hopp 76628d
+                         else
Karsten Hopp 76628d
+ # endif
Karsten Hopp 76628d
  			/* if xterm version >= 95 use mouse dragging */
Karsten Hopp 76628d
  			if (extra >= 95
Karsten Hopp 76628d
  # ifdef TTYM_URXVT
Karsten Hopp 76628d
***************
Karsten Hopp 76628d
*** 4147,4167 ****
Karsten Hopp 76628d
  	/*
Karsten Hopp 76628d
  	 * If it is a mouse click, get the coordinates.
Karsten Hopp 76628d
  	 */
Karsten Hopp 76628d
! 	if (key_name[0] == (int)KS_MOUSE
Karsten Hopp 76628d
  # ifdef FEAT_MOUSE_JSB
Karsten Hopp 76628d
! 		|| key_name[0] == (int)KS_JSBTERM_MOUSE
Karsten Hopp 76628d
  # endif
Karsten Hopp 76628d
  # ifdef FEAT_MOUSE_NET
Karsten Hopp 76628d
! 		|| key_name[0] == (int)KS_NETTERM_MOUSE
Karsten Hopp 76628d
  # endif
Karsten Hopp 76628d
  # ifdef FEAT_MOUSE_DEC
Karsten Hopp 76628d
! 		|| key_name[0] == (int)KS_DEC_MOUSE
Karsten Hopp 76628d
  # endif
Karsten Hopp 76628d
  # ifdef FEAT_MOUSE_PTERM
Karsten Hopp 76628d
! 		|| key_name[0] == (int)KS_PTERM_MOUSE
Karsten Hopp 76628d
  # endif
Karsten Hopp 76628d
  # ifdef FEAT_MOUSE_URXVT
Karsten Hopp 76628d
! 		|| key_name[0] == (int)KS_URXVT_MOUSE
Karsten Hopp 76628d
  # endif
Karsten Hopp 76628d
  		)
Karsten Hopp 76628d
  	{
Karsten Hopp 76628d
--- 4169,4192 ----
Karsten Hopp 76628d
  	/*
Karsten Hopp 76628d
  	 * If it is a mouse click, get the coordinates.
Karsten Hopp 76628d
  	 */
Karsten Hopp 76628d
! 	if (key_name[0] == KS_MOUSE
Karsten Hopp 76628d
  # ifdef FEAT_MOUSE_JSB
Karsten Hopp 76628d
! 		|| key_name[0] == KS_JSBTERM_MOUSE
Karsten Hopp 76628d
  # endif
Karsten Hopp 76628d
  # ifdef FEAT_MOUSE_NET
Karsten Hopp 76628d
! 		|| key_name[0] == KS_NETTERM_MOUSE
Karsten Hopp 76628d
  # endif
Karsten Hopp 76628d
  # ifdef FEAT_MOUSE_DEC
Karsten Hopp 76628d
! 		|| key_name[0] == KS_DEC_MOUSE
Karsten Hopp 76628d
  # endif
Karsten Hopp 76628d
  # ifdef FEAT_MOUSE_PTERM
Karsten Hopp 76628d
! 		|| key_name[0] == KS_PTERM_MOUSE
Karsten Hopp 76628d
  # endif
Karsten Hopp 76628d
  # ifdef FEAT_MOUSE_URXVT
Karsten Hopp 76628d
! 		|| key_name[0] == KS_URXVT_MOUSE
Karsten Hopp 76628d
! # endif
Karsten Hopp 76628d
! # ifdef FEAT_MOUSE_SGR
Karsten Hopp 76628d
! 		|| key_name[0] == KS_SGR_MOUSE
Karsten Hopp 76628d
  # endif
Karsten Hopp 76628d
  		)
Karsten Hopp 76628d
  	{
Karsten Hopp 76628d
***************
Karsten Hopp 76628d
*** 4243,4250 ****
Karsten Hopp 76628d
  		}
Karsten Hopp 76628d
  	    }
Karsten Hopp 76628d
  
Karsten Hopp 76628d
! # ifdef FEAT_MOUSE_URXVT
Karsten Hopp 76628d
! 	    if (key_name[0] == (int)KS_URXVT_MOUSE)
Karsten Hopp 76628d
  	    {
Karsten Hopp 76628d
  		for (;;)
Karsten Hopp 76628d
  		{
Karsten Hopp 76628d
--- 4268,4276 ----
Karsten Hopp 76628d
  		}
Karsten Hopp 76628d
  	    }
Karsten Hopp 76628d
  
Karsten Hopp 76628d
! # if defined(FEAT_MOUSE_URXVT) || defined(FEAT_MOUSE_SGR)
Karsten Hopp 76628d
! 	    if (key_name[0] == KS_URXVT_MOUSE
Karsten Hopp 76628d
! 		|| key_name[0] == KS_SGR_MOUSE)
Karsten Hopp 76628d
  	    {
Karsten Hopp 76628d
  		for (;;)
Karsten Hopp 76628d
  		{
Karsten Hopp 76628d
***************
Karsten Hopp 76628d
*** 4256,4261 ****
Karsten Hopp 76628d
--- 4282,4301 ----
Karsten Hopp 76628d
  		     *		  ^-- row
Karsten Hopp 76628d
  		     *	       ^----- column
Karsten Hopp 76628d
  		     *	    ^-------- code
Karsten Hopp 76628d
+ 		     *
Karsten Hopp 76628d
+ 		     * SGR 1006 mouse reporting mode:
Karsten Hopp 76628d
+ 		     * Almost identical to xterm mouse mode, except the values
Karsten Hopp 76628d
+ 		     * are decimal instead of bytes.
Karsten Hopp 76628d
+ 		     *
Karsten Hopp 76628d
+ 		     * \033[<%d;%d;%dM
Karsten Hopp 76628d
+ 		     *		   ^-- row
Karsten Hopp 76628d
+ 		     *	        ^----- column
Karsten Hopp 76628d
+ 		     *	     ^-------- code
Karsten Hopp 76628d
+ 		     *
Karsten Hopp 76628d
+ 		     * \033[<%d;%d;%dm        : mouse release event
Karsten Hopp 76628d
+ 		     *		   ^-- row
Karsten Hopp 76628d
+ 		     *	        ^----- column
Karsten Hopp 76628d
+ 		     *	     ^-------- code
Karsten Hopp 76628d
  		     */
Karsten Hopp 76628d
  		    p = tp + slen;
Karsten Hopp 76628d
  
Karsten Hopp 76628d
***************
Karsten Hopp 76628d
*** 4263,4294 ****
Karsten Hopp 76628d
  		    if (*p++ != ';')
Karsten Hopp 76628d
  			return -1;
Karsten Hopp 76628d
  
Karsten Hopp 76628d
  		    mouse_col = getdigits(&p) - 1;
Karsten Hopp 76628d
  		    if (*p++ != ';')
Karsten Hopp 76628d
  			return -1;
Karsten Hopp 76628d
  
Karsten Hopp 76628d
  		    mouse_row = getdigits(&p) - 1;
Karsten Hopp 76628d
! 		    if (*p++ != 'M')
Karsten Hopp 76628d
  			return -1;
Karsten Hopp 76628d
  
Karsten Hopp 76628d
  		    slen += (int)(p - (tp + slen));
Karsten Hopp 76628d
  
Karsten Hopp 76628d
  		    /* skip this one if next one has same code (like xterm
Karsten Hopp 76628d
  		     * case) */
Karsten Hopp 76628d
  		    j = termcodes[idx].len;
Karsten Hopp 76628d
! 		    if (STRNCMP(tp, tp + slen, (size_t)j) == 0) {
Karsten Hopp 76628d
! 			/* check if the command is complete by looking for the
Karsten Hopp 76628d
! 			 * M */
Karsten Hopp 76628d
  			int slen2;
Karsten Hopp 76628d
  			int cmd_complete = 0;
Karsten Hopp 76628d
! 			for (slen2 = slen; slen2 < len; slen2++) {
Karsten Hopp 76628d
! 			    if (tp[slen2] == 'M') {
Karsten Hopp 76628d
  				cmd_complete = 1;
Karsten Hopp 76628d
  				break;
Karsten Hopp 76628d
  			    }
Karsten Hopp 76628d
  			}
Karsten Hopp 76628d
  			p += j;
Karsten Hopp 76628d
! 			if (cmd_complete && getdigits(&p) == mouse_code) {
Karsten Hopp 76628d
  			    slen += j; /* skip the \033[ */
Karsten Hopp 76628d
  			    continue;
Karsten Hopp 76628d
  			}
Karsten Hopp 76628d
--- 4303,4348 ----
Karsten Hopp 76628d
  		    if (*p++ != ';')
Karsten Hopp 76628d
  			return -1;
Karsten Hopp 76628d
  
Karsten Hopp 76628d
+ 		    /* when mouse reporting is SGR, add 32 to mouse code */
Karsten Hopp 76628d
+                     if (key_name[0] == KS_SGR_MOUSE)
Karsten Hopp 76628d
+                         mouse_code += 32;
Karsten Hopp 76628d
+ 
Karsten Hopp 76628d
  		    mouse_col = getdigits(&p) - 1;
Karsten Hopp 76628d
  		    if (*p++ != ';')
Karsten Hopp 76628d
  			return -1;
Karsten Hopp 76628d
  
Karsten Hopp 76628d
  		    mouse_row = getdigits(&p) - 1;
Karsten Hopp 76628d
!                     if (key_name[0] == KS_SGR_MOUSE && *p == 'm')
Karsten Hopp 76628d
! 			mouse_code |= MOUSE_RELEASE;
Karsten Hopp 76628d
!                     else if (*p != 'M')
Karsten Hopp 76628d
  			return -1;
Karsten Hopp 76628d
+                     p++;
Karsten Hopp 76628d
  
Karsten Hopp 76628d
  		    slen += (int)(p - (tp + slen));
Karsten Hopp 76628d
  
Karsten Hopp 76628d
  		    /* skip this one if next one has same code (like xterm
Karsten Hopp 76628d
  		     * case) */
Karsten Hopp 76628d
  		    j = termcodes[idx].len;
Karsten Hopp 76628d
! 		    if (STRNCMP(tp, tp + slen, (size_t)j) == 0)
Karsten Hopp 76628d
! 		    {
Karsten Hopp 76628d
  			int slen2;
Karsten Hopp 76628d
  			int cmd_complete = 0;
Karsten Hopp 76628d
! 
Karsten Hopp 76628d
! 			/* check if the command is complete by looking for the
Karsten Hopp 76628d
! 			 * 'M' */
Karsten Hopp 76628d
! 			for (slen2 = slen; slen2 < len; slen2++)
Karsten Hopp 76628d
! 			{
Karsten Hopp 76628d
! 			    if (tp[slen2] == 'M'
Karsten Hopp 76628d
!                                 || (key_name[0] == KS_SGR_MOUSE
Karsten Hopp 76628d
! 							 && tp[slen2] == 'm'))
Karsten Hopp 76628d
! 			    {
Karsten Hopp 76628d
  				cmd_complete = 1;
Karsten Hopp 76628d
  				break;
Karsten Hopp 76628d
  			    }
Karsten Hopp 76628d
  			}
Karsten Hopp 76628d
  			p += j;
Karsten Hopp 76628d
! 			if (cmd_complete && getdigits(&p) == mouse_code)
Karsten Hopp 76628d
! 			{
Karsten Hopp 76628d
  			    slen += j; /* skip the \033[ */
Karsten Hopp 76628d
  			    continue;
Karsten Hopp 76628d
  			}
Karsten Hopp 76628d
***************
Karsten Hopp 76628d
*** 4302,4307 ****
Karsten Hopp 76628d
--- 4356,4364 ----
Karsten Hopp 76628d
  #ifdef FEAT_MOUSE_URXVT
Karsten Hopp 76628d
  	    || key_name[0] == (int)KS_URXVT_MOUSE
Karsten Hopp 76628d
  #endif
Karsten Hopp 76628d
+ #ifdef FEAT_MOUSE_SGR
Karsten Hopp 76628d
+ 	    || key_name[0] == KS_SGR_MOUSE
Karsten Hopp 76628d
+ #endif
Karsten Hopp 76628d
  	    )
Karsten Hopp 76628d
  	{
Karsten Hopp 76628d
  #  if !defined(MSWIN) && !defined(MSDOS)
Karsten Hopp 76628d
*** ../vim-7.3.631/src/version.c	2012-08-15 14:04:50.000000000 +0200
Karsten Hopp 76628d
--- src/version.c	2012-08-15 15:47:30.000000000 +0200
Karsten Hopp 76628d
***************
Karsten Hopp 76628d
*** 384,389 ****
Karsten Hopp 76628d
--- 384,394 ----
Karsten Hopp 76628d
  # else
Karsten Hopp 76628d
  	"-mouse_urxvt",
Karsten Hopp 76628d
  # endif
Karsten Hopp 76628d
+ # ifdef FEAT_MOUSE_SGR
Karsten Hopp 76628d
+ 	"+mouse_sgr",
Karsten Hopp 76628d
+ # else
Karsten Hopp 76628d
+ 	"-mouse_sgr",
Karsten Hopp 76628d
+ # endif
Karsten Hopp 76628d
  #endif
Karsten Hopp 76628d
  #ifdef __QNX__
Karsten Hopp 76628d
  # ifdef FEAT_MOUSE_PTERM
Karsten Hopp 76628d
*** ../vim-7.3.631/src/version.c	2012-08-15 14:04:50.000000000 +0200
Karsten Hopp 76628d
--- src/version.c	2012-08-15 15:47:30.000000000 +0200
Karsten Hopp 76628d
***************
Karsten Hopp 76628d
*** 716,717 ****
Karsten Hopp 76628d
--- 721,724 ----
Karsten Hopp 76628d
  {   /* Add new patch number below this line */
Karsten Hopp 76628d
+ /**/
Karsten Hopp 76628d
+     632,
Karsten Hopp 76628d
  /**/
Karsten Hopp 76628d
Karsten Hopp 76628d
-- 
Karsten Hopp 76628d
hundred-and-one symptoms of being an internet addict:
Karsten Hopp 76628d
243. You unsuccessfully try to download a pizza from www.dominos.com.
Karsten Hopp 76628d
Karsten Hopp 76628d
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 76628d
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 76628d
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 76628d
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///