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
155
156
157
158
|
use anes::parser::{KeyCode, KeyModifiers, Sequence};
use crate::test_sequences;
#[test]
fn esc_o_f_keys() {
test_sequences!(
b"\x1BOP",
Sequence::Key(KeyCode::F(1), KeyModifiers::empty()),
b"\x1BOQ",
Sequence::Key(KeyCode::F(2), KeyModifiers::empty()),
b"\x1BOR",
Sequence::Key(KeyCode::F(3), KeyModifiers::empty()),
b"\x1BOS",
Sequence::Key(KeyCode::F(4), KeyModifiers::empty()),
);
}
#[test]
fn csi_key_codes() {
test_sequences!(
b"\x1B[A",
Sequence::Key(KeyCode::Up, KeyModifiers::empty()),
b"\x1B[B",
Sequence::Key(KeyCode::Down, KeyModifiers::empty()),
b"\x1B[C",
Sequence::Key(KeyCode::Right, KeyModifiers::empty()),
b"\x1B[D",
Sequence::Key(KeyCode::Left, KeyModifiers::empty()),
b"\x1B[H",
Sequence::Key(KeyCode::Home, KeyModifiers::empty()),
b"\x1B[F",
Sequence::Key(KeyCode::End, KeyModifiers::empty()),
b"\x1B[Z",
Sequence::Key(KeyCode::BackTab, KeyModifiers::empty()),
);
}
#[test]
fn csi_arrow_key_modifiers() {
test_sequences!(
b"\x1B[50A",
Sequence::Key(KeyCode::Up, KeyModifiers::SHIFT),
b"\x1B[53A",
Sequence::Key(KeyCode::Up, KeyModifiers::CONTROL),
);
}
#[test]
fn csi_tilde_key_modifiers() {
test_sequences!(
b"\x1B[1~",
Sequence::Key(KeyCode::Home, KeyModifiers::empty()),
b"\x1B[1;0~",
Sequence::Key(KeyCode::Home, KeyModifiers::empty()),
b"\x1B[1;1~",
Sequence::Key(KeyCode::Home, KeyModifiers::empty()),
b"\x1B[1;2~",
Sequence::Key(KeyCode::Home, KeyModifiers::SHIFT),
b"\x1B[1;3~",
Sequence::Key(KeyCode::Home, KeyModifiers::ALT),
b"\x1B[1;4~",
Sequence::Key(KeyCode::Home, KeyModifiers::SHIFT | KeyModifiers::ALT),
b"\x1B[1;5~",
Sequence::Key(KeyCode::Home, KeyModifiers::CONTROL),
b"\x1B[1;6~",
Sequence::Key(KeyCode::Home, KeyModifiers::SHIFT | KeyModifiers::CONTROL),
b"\x1B[1;7~",
Sequence::Key(KeyCode::Home, KeyModifiers::ALT | KeyModifiers::CONTROL),
b"\x1B[1;8~",
Sequence::Key(
KeyCode::Home,
KeyModifiers::SHIFT | KeyModifiers::ALT | KeyModifiers::CONTROL
),
b"\x1B[1;9~",
Sequence::Key(KeyCode::Home, KeyModifiers::META),
b"\x1B[1;10~",
Sequence::Key(KeyCode::Home, KeyModifiers::META | KeyModifiers::SHIFT),
b"\x1B[1;11~",
Sequence::Key(KeyCode::Home, KeyModifiers::META | KeyModifiers::ALT),
b"\x1B[1;12~",
Sequence::Key(
KeyCode::Home,
KeyModifiers::META | KeyModifiers::SHIFT | KeyModifiers::ALT
),
b"\x1B[1;13~",
Sequence::Key(KeyCode::Home, KeyModifiers::META | KeyModifiers::CONTROL),
b"\x1B[1;14~",
Sequence::Key(
KeyCode::Home,
KeyModifiers::META | KeyModifiers::SHIFT | KeyModifiers::CONTROL
),
b"\x1B[1;15~",
Sequence::Key(
KeyCode::Home,
KeyModifiers::META | KeyModifiers::ALT | KeyModifiers::CONTROL
),
b"\x1B[1;16~",
Sequence::Key(
KeyCode::Home,
KeyModifiers::META | KeyModifiers::SHIFT | KeyModifiers::ALT | KeyModifiers::CONTROL
),
b"\x1B[1;17~",
Sequence::Key(KeyCode::Home, KeyModifiers::empty()),
);
}
#[test]
fn csi_tilde_f_keys() {
test_sequences!(
b"\x1B[11~",
Sequence::Key(KeyCode::F(1), KeyModifiers::empty()),
b"\x1B[12~",
Sequence::Key(KeyCode::F(2), KeyModifiers::empty()),
b"\x1B[13~",
Sequence::Key(KeyCode::F(3), KeyModifiers::empty()),
b"\x1B[14~",
Sequence::Key(KeyCode::F(4), KeyModifiers::empty()),
b"\x1B[15~",
Sequence::Key(KeyCode::F(5), KeyModifiers::empty()),
b"\x1B[17~",
Sequence::Key(KeyCode::F(6), KeyModifiers::empty()),
b"\x1B[18~",
Sequence::Key(KeyCode::F(7), KeyModifiers::empty()),
b"\x1B[19~",
Sequence::Key(KeyCode::F(8), KeyModifiers::empty()),
b"\x1B[20~",
Sequence::Key(KeyCode::F(9), KeyModifiers::empty()),
b"\x1B[21~",
Sequence::Key(KeyCode::F(10), KeyModifiers::empty()),
b"\x1B[23~",
Sequence::Key(KeyCode::F(11), KeyModifiers::empty()),
b"\x1B[24~",
Sequence::Key(KeyCode::F(12), KeyModifiers::empty()),
);
}
#[test]
fn csi_tilde_key_codes() {
test_sequences!(
b"\x1B[1~",
Sequence::Key(KeyCode::Home, KeyModifiers::empty()),
b"\x1B[2~",
Sequence::Key(KeyCode::Insert, KeyModifiers::empty()),
b"\x1B[3~",
Sequence::Key(KeyCode::Delete, KeyModifiers::empty()),
b"\x1B[4~",
Sequence::Key(KeyCode::End, KeyModifiers::empty()),
b"\x1B[5~",
Sequence::Key(KeyCode::PageUp, KeyModifiers::empty()),
b"\x1B[6~",
Sequence::Key(KeyCode::PageDown, KeyModifiers::empty()),
b"\x1B[7~",
Sequence::Key(KeyCode::Home, KeyModifiers::empty()),
b"\x1B[8~",
Sequence::Key(KeyCode::End, KeyModifiers::empty()),
);
}
|