Skip to content

Instantly share code, notes, and snippets.

@saitoha
Created May 20, 2013 15:05
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saitoha/5612807 to your computer and use it in GitHub Desktop.
Save saitoha/5612807 to your computer and use it in GitHub Desktop.
vim ttymouse auto detection for GNU Screen/tmux
diff -r e56bf2af53c0 src/os_unix.c
--- a/src/os_unix.c Wed May 15 23:13:10 2013 +0200
+++ b/src/os_unix.c Tue May 21 00:04:11 2013 +0900
@@ -2190,6 +2190,7 @@
|| STRNICMP(name, "kterm", 5) == 0
|| STRNICMP(name, "mlterm", 6) == 0
|| STRNICMP(name, "rxvt", 4) == 0
+ || STRNICMP(name, "screen", 6) == 0
|| STRCMP(name, "builtin_xterm") == 0);
}
diff -r e56bf2af53c0 src/term.c
--- a/src/term.c Wed May 15 23:13:10 2013 +0200
+++ b/src/term.c Tue May 21 00:04:11 2013 +0900
@@ -4179,13 +4179,27 @@
if (tp[0] == CSI)
switch_to_8bit();
+ if (extra > 0)
+ extra = atoi((char *)tp + extra);
/* rxvt sends its version number: "20703" is 2.7.3.
* Ignore it for when the user has set 'term' to xterm,
* even though it's an rxvt. */
- if (extra > 0)
- extra = atoi((char *)tp + extra);
if (extra > 20000)
- extra = 0;
+ {
+ /* check terminal ID */
+ switch(atoi((char *)tp + 2 + (tp[0] != CSI)))
+ {
+ case 'R': /* rxvt, ck */
+ extra = 0;
+ break;
+ case 'S': /* GNU Screen */
+ extra = 95;
+ break;
+ default:
+ extra = 95;
+ break;
+ }
+ }
if (tp[1 + (tp[0] != CSI)] == '>' && j == 2)
{
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment