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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
|
use anes::parser::{KeyModifiers, Mouse, MouseButton, Sequence};
use crate::test_sequences;
#[test]
fn button_down() {
test_sequences!(
b"\x1B[<0;20;10;M",
Sequence::Mouse(
Mouse::Down(MouseButton::Left, 20, 10),
KeyModifiers::empty()
),
b"\x1B[<1;20;10;M",
Sequence::Mouse(
Mouse::Down(MouseButton::Middle, 20, 10),
KeyModifiers::empty()
),
b"\x1B[<2;20;10;M",
Sequence::Mouse(
Mouse::Down(MouseButton::Right, 20, 10),
KeyModifiers::empty()
),
);
}
#[test]
fn button_down_with_key_modifiers() {
test_sequences!(
b"\x1B[<4;20;10;M",
Sequence::Mouse(Mouse::Down(MouseButton::Left, 20, 10), KeyModifiers::SHIFT),
b"\x1B[<5;20;10;M",
Sequence::Mouse(
Mouse::Down(MouseButton::Middle, 20, 10),
KeyModifiers::SHIFT
),
b"\x1B[<6;20;10;M",
Sequence::Mouse(Mouse::Down(MouseButton::Right, 20, 10), KeyModifiers::SHIFT),
);
}
#[test]
fn button_up() {
test_sequences!(
b"\x1B[<0;20;10;m",
Sequence::Mouse(Mouse::Up(MouseButton::Left, 20, 10), KeyModifiers::empty()),
b"\x1B[<1;20;10;m",
Sequence::Mouse(
Mouse::Up(MouseButton::Middle, 20, 10),
KeyModifiers::empty()
),
b"\x1B[<2;20;10;m",
Sequence::Mouse(Mouse::Up(MouseButton::Right, 20, 10), KeyModifiers::empty()),
);
}
#[test]
fn button_up_with_key_modifiers() {
test_sequences!(
b"\x1B[<4;20;10;m",
Sequence::Mouse(Mouse::Up(MouseButton::Left, 20, 10), KeyModifiers::SHIFT),
b"\x1B[<5;20;10;m",
Sequence::Mouse(Mouse::Up(MouseButton::Middle, 20, 10), KeyModifiers::SHIFT),
b"\x1B[<6;20;10;m",
Sequence::Mouse(Mouse::Up(MouseButton::Right, 20, 10), KeyModifiers::SHIFT),
);
}
#[test]
fn scroll() {
test_sequences!(
b"\x1B[<64;20;10;m",
Sequence::Mouse(Mouse::ScrollUp(20, 10), KeyModifiers::empty()),
b"\x1B[<65;20;10;m",
Sequence::Mouse(Mouse::ScrollDown(20, 10), KeyModifiers::empty()),
);
}
#[test]
fn scroll_with_key_modifiers() {
test_sequences!(
b"\x1B[<68;20;10;m",
Sequence::Mouse(Mouse::ScrollUp(20, 10), KeyModifiers::SHIFT),
b"\x1B[<69;20;10;m",
Sequence::Mouse(Mouse::ScrollDown(20, 10), KeyModifiers::SHIFT),
);
}
#[test]
fn drag() {
test_sequences!(
b"\x1B[<32;20;10;M",
Sequence::Mouse(
Mouse::Drag(MouseButton::Left, 20, 10),
KeyModifiers::empty()
),
b"\x1B[<33;20;10;M",
Sequence::Mouse(
Mouse::Drag(MouseButton::Middle, 20, 10),
KeyModifiers::empty()
),
b"\x1B[<34;20;10;M",
Sequence::Mouse(
Mouse::Drag(MouseButton::Right, 20, 10),
KeyModifiers::empty()
),
);
}
#[test]
fn drag_with_key_modifiers() {
test_sequences!(
b"\x1B[<36;20;10;M",
Sequence::Mouse(Mouse::Drag(MouseButton::Left, 20, 10), KeyModifiers::SHIFT),
b"\x1B[<37;20;10;M",
Sequence::Mouse(
Mouse::Drag(MouseButton::Middle, 20, 10),
KeyModifiers::SHIFT,
),
b"\x1B[<38;20;10;M",
Sequence::Mouse(Mouse::Drag(MouseButton::Right, 20, 10), KeyModifiers::SHIFT),
);
}
#[test]
fn key_modifier_combinations() {
test_sequences!(
b"\x1B[<4;20;10;m",
Sequence::Mouse(Mouse::Up(MouseButton::Left, 20, 10), KeyModifiers::SHIFT),
b"\x1B[<8;20;10;m",
Sequence::Mouse(Mouse::Up(MouseButton::Left, 20, 10), KeyModifiers::ALT),
b"\x1B[<16;20;10;m",
Sequence::Mouse(Mouse::Up(MouseButton::Left, 20, 10), KeyModifiers::CONTROL),
b"\x1B[<12;20;10;m",
Sequence::Mouse(
Mouse::Up(MouseButton::Left, 20, 10),
KeyModifiers::SHIFT | KeyModifiers::ALT
),
b"\x1B[<20;20;10;m",
Sequence::Mouse(
Mouse::Up(MouseButton::Left, 20, 10),
KeyModifiers::SHIFT | KeyModifiers::CONTROL
),
b"\x1B[<24;20;10;m",
Sequence::Mouse(
Mouse::Up(MouseButton::Left, 20, 10),
KeyModifiers::ALT | KeyModifiers::CONTROL
),
b"\x1B[<28;20;10;m",
Sequence::Mouse(
Mouse::Up(MouseButton::Left, 20, 10),
KeyModifiers::SHIFT | KeyModifiers::ALT | KeyModifiers::CONTROL
),
);
}
|