diff src/os_unix.c @ 3746:44038a9777aa v7.3.632

updated for version 7.3.632 Problem: Cannot select beyond 222 columns with the mouse in xterm. Solution: Add support for SGR mouse tracking. (Hayaki Saito)
author Bram Moolenaar <bram@vim.org>
date Wed, 15 Aug 2012 16:21:32 +0200
parents 4a2cb025b641
children ad5fbf3596e0
line wrap: on
line diff
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -2159,10 +2159,13 @@ use_xterm_like_mouse(name)
  * Return 1 for "xterm".
  * Return 2 for "xterm2".
  * Return 3 for "urxvt".
+ * Return 4 for "sgr".
  */
     int
 use_xterm_mouse()
 {
+    if (ttym_flags == TTYM_SGR)
+	return 4;
     if (ttym_flags == TTYM_URXVT)
 	return 3;
     if (ttym_flags == TTYM_XTERM2)
@@ -3339,7 +3342,8 @@ mch_setmouse(on)
     xterm_mouse_vers = use_xterm_mouse();
 
 # ifdef FEAT_MOUSE_URXVT
-    if (ttym_flags == TTYM_URXVT) {
+    if (ttym_flags == TTYM_URXVT)
+    {
 	out_str_nf((char_u *)
 		   (on
 		   ? IF_EB("\033[?1015h", ESC_STR "[?1015h")
@@ -3348,6 +3352,17 @@ mch_setmouse(on)
     }
 # endif
 
+# ifdef FEAT_MOUSE_SGR
+    if (ttym_flags == TTYM_SGR)
+    {
+	out_str_nf((char_u *)
+		   (on
+		   ? IF_EB("\033[?1006h", ESC_STR "[?1006h")
+		   : IF_EB("\033[?1006l", ESC_STR "[?1006l")));
+	ison = on;
+    }
+# endif
+
     if (xterm_mouse_vers > 0)
     {
 	if (on)	/* enable mouse events, use mouse tracking if available */
@@ -3577,6 +3592,27 @@ check_mouse_termcode()
     else
 	del_mouse_termcode(KS_URXVT_MOUSE);
 # endif
+# ifdef FEAT_MOUSE_SGR
+    /* same as the dec mouse */
+    if (use_xterm_mouse() == 4
+#  ifdef FEAT_GUI
+	    && !gui.in_use
+#  endif
+	    )
+    {
+	set_mouse_termcode(KS_SGR_MOUSE, (char_u *)(term_is_8bit(T_NAME)
+		    ? IF_EB("\233<", CSI_STR "<")
+		    : IF_EB("\033[<", ESC_STR "[<")));
+
+	if (*p_mouse != NUL)
+	{
+	    mch_setmouse(FALSE);
+	    setmouse();
+	}
+    }
+    else
+	del_mouse_termcode(KS_SGR_MOUSE);
+# endif
 }
 #endif