-
Notifications
You must be signed in to change notification settings - Fork 4
/
sgr-mouse-mode.patch
94 lines (86 loc) · 3.56 KB
/
sgr-mouse-mode.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
Source: https://gist.githubusercontent.com/alexoj/df5bae7a4825cb596581/raw/75a1e75c2ae1ec5c0db68a29f8a6821e9e3d87a5/sgr-mouse-mode.patch
Upated to work with CVS (focus reporting)
--- src/command.C 2014-12-13 13:22:09.000000000 +0100
+++ src/command.C 2016-01-13 04:50:39.161862513 +0100
@@ -1280,6 +1280,8 @@
int x, y;
int code = 32;
+ if (priv_modes & PrivMode_ExtMouseSgr) code = 0;
+
x = Pixel2Col (ev.x) + 1;
y = Pixel2Row (ev.y) + 1;
@@ -1293,11 +1295,18 @@
code += 32;
}
- if (MEvent.button == AnyButton)
+ if (!(priv_modes & PrivMode_ExtMouseSgr) && MEvent.button == AnyButton)
button_number = 3;
else
{
- button_number = MEvent.button - Button1;
+ if (ev.type == MotionNotify) {
+ if (ev.state & Button1Mask) button_number = 0;
+ else if (ev.state & Button2Mask) button_number = 1;
+ else if (ev.state & Button3Mask) button_number = 2;
+ else return;
+ } else {
+ button_number = ev.button - Button1;
+ }
/* add 0x3D for wheel events, like xterm does */
if (button_number >= 3)
button_number += 64 - 3;
@@ -1347,16 +1356,22 @@
#endif
#if ENABLE_FRILLS
+ if (priv_modes & PrivMode_ExtMouseSgr)
+ tt_printf ("\033[<%d;%d;%d%c",
+ code + button_number + key_state,
+ x,
+ y,
+ (ev.type == ButtonRelease ? 'm' : 'M'));
- if (priv_modes & PrivMode_ExtMouseRight)
+ else if (priv_modes & PrivMode_ExtMouseRight)
tt_printf ("\033[%d;%d;%dM",
code + button_number + key_state,
x,
y);
else if (priv_modes & PrivMode_ExtModeMouse)
tt_printf ("\033[M%c%lc%lc",
code + button_number + key_state,
wint_t (32 + x),
wint_t (32 + y));
else
#endif
tt_printf ("\033[M%c%c%c",
@@ -2908,7 +2913,7 @@
scr_soft_reset ();
static const int pm_h[] = { 7, 25 };
- static const int pm_l[] = { 1, 3, 4, 5, 6, 9, 66, 1000, 1001, 1005, 1015, 1049 };
+ static const int pm_l[] = { 1, 3, 4, 5, 6, 9, 66, 1000, 1001, 1002, 1003, 1005, 1006, 1015, 1049 };
process_terminal_mode ('h', 0, ecb_array_length (pm_h), pm_h);
process_terminal_mode ('l', 0, ecb_array_length (pm_l), pm_l);
@@ -3713,13 +3718,14 @@
{ 1002, PrivMode_MouseBtnEvent },
{ 1003, PrivMode_MouseAnyEvent },
#if ENABLE_FRILLS
{ 1004, PrivMode_FocusEvent },
{ 1005, PrivMode_ExtModeMouse },
+ { 1006, PrivMode_ExtMouseSgr },
#endif
{ 1010, PrivMode_TtyOutputInh }, // rxvt extension
{ 1011, PrivMode_Keypress }, // rxvt extension
#if ENABLE_FRILLS
{ 1015, PrivMode_ExtMouseRight }, // urxvt extension of 1005
#endif
// 1035 enable modifiers for alt, numlock NYI
// 1036 send ESC for meta keys NYI
// 1037 send DEL for keypad delete NYI
--- src/rxvt.h 2014-12-17 16:33:08.000000000 +0100
+++ src/rxvt.h 2016-01-13 03:42:31.508911380 +0100
@@ -644,6 +644,7 @@
#define PrivMode_ExtModeMouse (1UL<<23) // xterm pseudo-utf-8 hack
#define PrivMode_ExtMouseRight (1UL<<24) // xterm pseudo-utf-8, but works in non-utf-8-locales
#define PrivMode_BlinkingCursor (1UL<<25)
#define PrivMode_FocusEvent (1UL<<26)
+#define PrivMode_ExtMouseSgr (1UL<<27) // sgr mouse extension
#define PrivMode_mouse_report (PrivMode_MouseX10|PrivMode_MouseX11|PrivMode_MouseBtnEvent|PrivMode_MouseAnyEvent)