This repository was archived by the owner on Sep 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathhterm_parser_identifiers.js
334 lines (308 loc) · 6.71 KB
/
hterm_parser_identifiers.js
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
// Copyright (c) 2015 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
'use strict';
/**
* Collections of identifier for hterm.Parser.
*/
hterm.Parser.identifiers = {};
/**
* Modifier key names used when defining key sequences.
*
* These are upper case so we can normalize the user input and be forgiving.
* "CTRL+A" and "Ctrl+A" and "ctrl+a" are all accepted.
*
* Note: Names here cannot overlap with hterm.Parser.identifiers.keyCodes.
*/
hterm.Parser.identifiers.modifierKeys = {
SHIFT: 'shift',
CTRL: 'ctrl',
// Common alias.
CONTROL: 'ctrl',
ALT: 'alt',
META: 'meta',
};
/**
* Key codes useful when defining key sequences.
*
* Punctuation is mostly left out of this list because they can move around
* based on keyboard locale and browser.
*
* In a key sequence like "Ctrl+ESC", the ESC comes from this list of
* identifiers. It is equivalent to "Ctrl+27" and "Ctrl+0x1b".
*
* These are upper case so we can normalize the user input and be forgiving.
* "Ctrl+ESC" and "Ctrl+Esc" an "Ctrl+esc" are all accepted.
*
* We also include common aliases for the same key. "Esc" and "Escape" are the
* same key.
*
* Note: Names here cannot overlap with hterm.Parser.identifiers.modifierKeys.
*/
hterm.Parser.identifiers.keyCodes = {
// Top row.
ESCAPE: 27,
ESC: 27,
F1: 112,
F2: 113,
F3: 114,
F4: 115,
F5: 116,
F6: 117,
F7: 118,
F8: 119,
F9: 120,
F10: 121,
F11: 122,
F12: 123,
// Row two.
ONE: 49,
TWO: 50,
THREE: 51,
FOUR: 52,
FIVE: 53,
SIX: 54,
SEVEN: 55,
EIGHT: 56,
NINE: 57,
ZERO: 48,
MINUS: 189,
EQUAL: 187,
BACKSPACE: 8,
BKSP: 8,
BS: 8,
// Row three.
TAB: 9,
Q: 81,
W: 87,
E: 69,
R: 82,
T: 84,
Y: 89,
U: 85,
// eslint-disable-next-line id-blacklist
I: 73,
O: 79,
P: 80,
BRACKET_LEFT: 219,
BRACKET_RIGHT: 221,
// Row four.
CAPS_LOCK: 20,
CAPSLOCK: 20,
CAPS: 20,
A: 65,
S: 83,
D: 68,
F: 70,
G: 71,
H: 72,
J: 74,
K: 75,
L: 76,
// We map enter and return together even though enter should really be 10
// because most people don't know or care about the history here. Plus,
// most keyboards/programs map them together already. If they really want
// to bind them differently, they can also use the numeric value.
ENTER: 13,
ENT: 13,
RETURN: 13,
RET: 13,
// Row five.
Z: 90,
X: 88,
C: 67,
V: 86,
B: 66,
N: 78,
M: 77,
// Etc.
SPACE: 32,
SP: 32,
PRINT_SCREEN: 42,
PRTSC: 42,
SCROLL_LOCK: 145,
SCRLK: 145,
BREAK: 19,
BRK: 19,
INSERT: 45,
INS: 45,
HOME: 36,
PAGE_UP: 33,
PGUP: 33,
DELETE: 46,
DEL: 46,
END: 35,
PAGE_DOWN: 34,
PGDOWN: 34,
PGDN: 34,
UP: 38,
DOWN: 40,
RIGHT: 39,
LEFT: 37,
NUMLOCK: 144,
// Keypad
KP0: 96,
KP1: 97,
KP2: 98,
KP3: 99,
KP4: 100,
KP5: 101,
KP6: 102,
KP7: 103,
KP8: 104,
KP9: 105,
KP_PLUS: 107,
KP_ADD: 107,
KP_MINUS: 109,
KP_SUBTRACT: 109,
KP_STAR: 106,
KP_MULTIPLY: 106,
KP_DIVIDE: 111,
KP_DECIMAL: 110,
KP_PERIOD: 110,
// Chrome OS media keys
NAVIGATE_BACK: 166,
NAVIGATE_FORWARD: 167,
RELOAD: 168,
FULL_SCREEN: 183,
WINDOW_OVERVIEW: 182,
BRIGHTNESS_UP: 216,
BRIGHTNESS_DOWN: 217,
};
/**
* Identifiers for use in key actions.
*/
hterm.Parser.identifiers.actions = {
/**
* Prevent the browser and operating system from handling the event.
*/
CANCEL: hterm.Keyboard.KeyActions.CANCEL,
/**
* Wait for a "keypress" event, send the keypress charCode to the host.
*/
DEFAULT: hterm.Keyboard.KeyActions.DEFAULT,
/**
* Let the browser or operating system handle the key.
*/
PASS: hterm.Keyboard.KeyActions.PASS,
/**
* Scroll the terminal one line up.
*
* @param {!hterm.Terminal} terminal
* @return {!hterm.Keyboard.KeyActions}
*/
scrollLineUp: function(terminal) {
terminal.scrollLineUp();
return hterm.Keyboard.KeyActions.CANCEL;
},
/**
* Scroll the terminal one line down.
*
* @param {!hterm.Terminal} terminal
* @return {!hterm.Keyboard.KeyActions}
*/
scrollLineDown: function(terminal) {
terminal.scrollLineDown();
return hterm.Keyboard.KeyActions.CANCEL;
},
/**
* Scroll the terminal one page up.
*
* @param {!hterm.Terminal} terminal
* @return {!hterm.Keyboard.KeyActions}
*/
scrollPageUp: function(terminal) {
terminal.scrollPageUp();
return hterm.Keyboard.KeyActions.CANCEL;
},
/**
* Scroll the terminal one page down.
*
* @param {!hterm.Terminal} terminal
* @return {!hterm.Keyboard.KeyActions}
*/
scrollPageDown: function(terminal) {
terminal.scrollPageDown();
return hterm.Keyboard.KeyActions.CANCEL;
},
/**
* Scroll the terminal to the top.
*
* @param {!hterm.Terminal} terminal
* @return {!hterm.Keyboard.KeyActions}
*/
scrollToTop: function(terminal) {
terminal.scrollHome();
return hterm.Keyboard.KeyActions.CANCEL;
},
/**
* Scroll the terminal to the bottom.
*
* @param {!hterm.Terminal} terminal
* @return {!hterm.Keyboard.KeyActions}
*/
scrollToBottom: function(terminal) {
terminal.scrollEnd();
return hterm.Keyboard.KeyActions.CANCEL;
},
/**
* Select all lines in the terminal buffer.
*
* @param {!hterm.Terminal} terminal
* @return {!hterm.Keyboard.KeyActions}
*/
selectAll: function(terminal) {
terminal.getScrollPort().selectAll();
return hterm.Keyboard.KeyActions.CANCEL;
},
/**
* Clear the active screen and move the cursor to (0,0).
*
* @param {!hterm.Terminal} terminal
* @return {!hterm.Keyboard.KeyActions}
*/
clearScreen: function(terminal) {
terminal.clearHome();
return hterm.Keyboard.KeyActions.CANCEL;
},
/**
* Clear the scrollback buffer.
*
* @param {!hterm.Terminal} terminal
* @return {!hterm.Keyboard.KeyActions}
*/
clearScrollback: function(terminal) {
terminal.clearScrollback();
return hterm.Keyboard.KeyActions.CANCEL;
},
/**
* Clear the terminal and scrollback buffer and move the cursor to (0,0).
*
* @param {!hterm.Terminal} terminal
* @return {!hterm.Keyboard.KeyActions}
*/
clearTerminal: function(terminal) {
terminal.wipeContents();
return hterm.Keyboard.KeyActions.CANCEL;
},
/**
* Perform a full terminal reset.
*
* @param {!hterm.Terminal} terminal
* @return {!hterm.Keyboard.KeyActions}
*/
fullReset: function(terminal) {
terminal.reset();
return hterm.Keyboard.KeyActions.CANCEL;
},
/**
* Perform a soft terminal reset.
*
* @param {!hterm.Terminal} terminal
* @return {!hterm.Keyboard.KeyActions}
*/
softReset: function(terminal) {
terminal.softReset();
return hterm.Keyboard.KeyActions.CANCEL;
},
};