@codingame/monaco-vscode-keybindings-service-override 4.0.0 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/keybindings.js +6 -6
- package/package.json +9 -9
- package/vscode/src/vs/platform/keyboardLayout/common/keyboardConfig.js +0 -50
- package/vscode/src/vs/platform/keyboardLayout/common/keyboardMapper.js +0 -24
- package/vscode/src/vs/workbench/contrib/commands/common/commands.contribution.js +0 -146
- package/vscode/src/vs/workbench/contrib/keybindings/browser/keybindings.contribution.js +0 -29
- package/vscode/src/vs/workbench/contrib/preferences/browser/keybindingsEditorContribution.js +0 -250
- package/vscode/src/vs/workbench/contrib/preferences/common/smartSnippetInserter.js +0 -126
- package/vscode/src/vs/workbench/services/actions/common/menusExtensionPoint.js +0 -1597
- package/vscode/src/vs/workbench/services/commands/common/commandService.js +0 -79
- package/vscode/src/vs/workbench/services/keybinding/browser/keybindingService.js +0 -947
- package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayoutService.js +0 -502
- package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/_.contribution.js +0 -14
- package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/cz.win.js +0 -163
- package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/de-swiss.win.js +0 -163
- package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/de.darwin.js +0 -126
- package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/de.linux.js +0 -181
- package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/de.win.js +0 -163
- package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/dk.win.js +0 -163
- package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/dvorak.darwin.js +0 -126
- package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/en-belgian.win.js +0 -163
- package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/en-ext.darwin.js +0 -126
- package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/en-in.win.js +0 -163
- package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/en-intl.darwin.js +0 -126
- package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/en-intl.win.js +0 -163
- package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/en-uk.darwin.js +0 -126
- package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/en-uk.win.js +0 -163
- package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/en.darwin.js +0 -134
- package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/en.linux.js +0 -183
- package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/en.win.js +0 -168
- package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/es-latin.win.js +0 -163
- package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/es.darwin.js +0 -126
- package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/es.linux.js +0 -181
- package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/es.win.js +0 -163
- package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/fr.darwin.js +0 -126
- package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/fr.linux.js +0 -181
- package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/fr.win.js +0 -163
- package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/hu.win.js +0 -163
- package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/it.darwin.js +0 -126
- package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/it.win.js +0 -163
- package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/jp-roman.darwin.js +0 -126
- package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/jp.darwin.js +0 -126
- package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/ko.darwin.js +0 -126
- package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/layout.contribution.darwin.js +0 -17
- package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/layout.contribution.linux.js +0 -6
- package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/layout.contribution.win.js +0 -23
- package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/no.win.js +0 -163
- package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/pl.darwin.js +0 -126
- package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/pl.win.js +0 -163
- package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/pt-br.win.js +0 -163
- package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/pt.darwin.js +0 -126
- package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/pt.win.js +0 -163
- package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/ru.darwin.js +0 -126
- package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/ru.linux.js +0 -181
- package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/ru.win.js +0 -163
- package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/sv.win.js +0 -165
- package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/thai.win.js +0 -163
- package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/tr.win.js +0 -163
- package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/zh-hans.darwin.js +0 -126
- package/vscode/src/vs/workbench/services/keybinding/common/keybindingIO.js +0 -74
- package/vscode/src/vs/workbench/services/keybinding/common/keymapInfo.js +0 -110
- package/vscode/src/vs/workbench/services/keybinding/common/macLinuxKeyboardMapper.js +0 -888
- package/vscode/src/vs/workbench/services/keybinding/common/windowsKeyboardMapper.js +0 -352
|
@@ -1,888 +0,0 @@
|
|
|
1
|
-
import { IMMUTABLE_CODE_TO_KEY_CODE, KeyCodeUtils, ScanCodeUtils, IMMUTABLE_KEY_CODE_TO_CODE } from 'vscode/vscode/vs/base/common/keyCodes';
|
|
2
|
-
import { ScanCodeChord, KeyCodeChord } from 'vscode/vscode/vs/base/common/keybindings';
|
|
3
|
-
import { BaseResolvedKeybinding } from 'vscode/vscode/vs/platform/keybinding/common/baseResolvedKeybinding';
|
|
4
|
-
|
|
5
|
-
const CHAR_CODE_TO_KEY_CODE = [];
|
|
6
|
-
class NativeResolvedKeybinding extends BaseResolvedKeybinding {
|
|
7
|
-
constructor(mapper, os, chords) {
|
|
8
|
-
super(os, chords);
|
|
9
|
-
this._mapper = mapper;
|
|
10
|
-
}
|
|
11
|
-
_getLabel(chord) {
|
|
12
|
-
return this._mapper.getUILabelForScanCodeChord(chord);
|
|
13
|
-
}
|
|
14
|
-
_getAriaLabel(chord) {
|
|
15
|
-
return this._mapper.getAriaLabelForScanCodeChord(chord);
|
|
16
|
-
}
|
|
17
|
-
_getElectronAccelerator(chord) {
|
|
18
|
-
return this._mapper.getElectronAcceleratorLabelForScanCodeChord(chord);
|
|
19
|
-
}
|
|
20
|
-
_getUserSettingsLabel(chord) {
|
|
21
|
-
return this._mapper.getUserSettingsLabelForScanCodeChord(chord);
|
|
22
|
-
}
|
|
23
|
-
_isWYSIWYG(binding) {
|
|
24
|
-
if (!binding) {
|
|
25
|
-
return true;
|
|
26
|
-
}
|
|
27
|
-
if (IMMUTABLE_CODE_TO_KEY_CODE[binding.scanCode] !== -1 ) {
|
|
28
|
-
return true;
|
|
29
|
-
}
|
|
30
|
-
const a = this._mapper.getAriaLabelForScanCodeChord(binding);
|
|
31
|
-
const b = this._mapper.getUserSettingsLabelForScanCodeChord(binding);
|
|
32
|
-
if (!a && !b) {
|
|
33
|
-
return true;
|
|
34
|
-
}
|
|
35
|
-
if (!a || !b) {
|
|
36
|
-
return false;
|
|
37
|
-
}
|
|
38
|
-
return (a.toLowerCase() === b.toLowerCase());
|
|
39
|
-
}
|
|
40
|
-
_getChordDispatch(chord) {
|
|
41
|
-
return this._mapper.getDispatchStrForScanCodeChord(chord);
|
|
42
|
-
}
|
|
43
|
-
_getSingleModifierChordDispatch(chord) {
|
|
44
|
-
if (((chord.scanCode === 157 || chord.scanCode === 161) ) && !chord.shiftKey && !chord.altKey && !chord.metaKey) {
|
|
45
|
-
return 'ctrl';
|
|
46
|
-
}
|
|
47
|
-
if (((chord.scanCode === 159 || chord.scanCode === 163) ) && !chord.ctrlKey && !chord.shiftKey && !chord.metaKey) {
|
|
48
|
-
return 'alt';
|
|
49
|
-
}
|
|
50
|
-
if (((chord.scanCode === 158 || chord.scanCode === 162) ) && !chord.ctrlKey && !chord.altKey && !chord.metaKey) {
|
|
51
|
-
return 'shift';
|
|
52
|
-
}
|
|
53
|
-
if (((chord.scanCode === 160 || chord.scanCode === 164) ) && !chord.ctrlKey && !chord.shiftKey && !chord.altKey) {
|
|
54
|
-
return 'meta';
|
|
55
|
-
}
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
class ScanCodeCombo {
|
|
60
|
-
constructor(ctrlKey, shiftKey, altKey, scanCode) {
|
|
61
|
-
this.ctrlKey = ctrlKey;
|
|
62
|
-
this.shiftKey = shiftKey;
|
|
63
|
-
this.altKey = altKey;
|
|
64
|
-
this.scanCode = scanCode;
|
|
65
|
-
}
|
|
66
|
-
toString() {
|
|
67
|
-
return `${this.ctrlKey ? 'Ctrl+' : ''}${this.shiftKey ? 'Shift+' : ''}${this.altKey ? 'Alt+' : ''}${( ScanCodeUtils.toString(this.scanCode))}`;
|
|
68
|
-
}
|
|
69
|
-
equals(other) {
|
|
70
|
-
return (this.ctrlKey === other.ctrlKey
|
|
71
|
-
&& this.shiftKey === other.shiftKey
|
|
72
|
-
&& this.altKey === other.altKey
|
|
73
|
-
&& this.scanCode === other.scanCode);
|
|
74
|
-
}
|
|
75
|
-
getProducedCharCode(mapping) {
|
|
76
|
-
if (!mapping) {
|
|
77
|
-
return '';
|
|
78
|
-
}
|
|
79
|
-
if (this.ctrlKey && this.shiftKey && this.altKey) {
|
|
80
|
-
return mapping.withShiftAltGr;
|
|
81
|
-
}
|
|
82
|
-
if (this.ctrlKey && this.altKey) {
|
|
83
|
-
return mapping.withAltGr;
|
|
84
|
-
}
|
|
85
|
-
if (this.shiftKey) {
|
|
86
|
-
return mapping.withShift;
|
|
87
|
-
}
|
|
88
|
-
return mapping.value;
|
|
89
|
-
}
|
|
90
|
-
getProducedChar(mapping) {
|
|
91
|
-
const charCode = MacLinuxKeyboardMapper.getCharCode(this.getProducedCharCode(mapping));
|
|
92
|
-
if (charCode === 0) {
|
|
93
|
-
return ' --- ';
|
|
94
|
-
}
|
|
95
|
-
if (charCode >= 768 && charCode <= 879 ) {
|
|
96
|
-
return 'U+' + ( charCode.toString(16));
|
|
97
|
-
}
|
|
98
|
-
return ' ' + String.fromCharCode(charCode) + ' ';
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
class KeyCodeCombo {
|
|
102
|
-
constructor(ctrlKey, shiftKey, altKey, keyCode) {
|
|
103
|
-
this.ctrlKey = ctrlKey;
|
|
104
|
-
this.shiftKey = shiftKey;
|
|
105
|
-
this.altKey = altKey;
|
|
106
|
-
this.keyCode = keyCode;
|
|
107
|
-
}
|
|
108
|
-
toString() {
|
|
109
|
-
return `${this.ctrlKey ? 'Ctrl+' : ''}${this.shiftKey ? 'Shift+' : ''}${this.altKey ? 'Alt+' : ''}${( KeyCodeUtils.toString(this.keyCode))}`;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
class ScanCodeKeyCodeMapper {
|
|
113
|
-
constructor() {
|
|
114
|
-
this._scanCodeToKeyCode = [];
|
|
115
|
-
this._keyCodeToScanCode = [];
|
|
116
|
-
this._scanCodeToKeyCode = [];
|
|
117
|
-
this._keyCodeToScanCode = [];
|
|
118
|
-
}
|
|
119
|
-
registrationComplete() {
|
|
120
|
-
this._moveToEnd(56 );
|
|
121
|
-
this._moveToEnd(106 );
|
|
122
|
-
}
|
|
123
|
-
_moveToEnd(scanCode) {
|
|
124
|
-
for (let mod = 0; mod < 8; mod++) {
|
|
125
|
-
const encodedKeyCodeCombos = this._scanCodeToKeyCode[(scanCode << 3) + mod];
|
|
126
|
-
if (!encodedKeyCodeCombos) {
|
|
127
|
-
continue;
|
|
128
|
-
}
|
|
129
|
-
for (let i = 0, len = encodedKeyCodeCombos.length; i < len; i++) {
|
|
130
|
-
const encodedScanCodeCombos = this._keyCodeToScanCode[encodedKeyCodeCombos[i]];
|
|
131
|
-
if (encodedScanCodeCombos.length === 1) {
|
|
132
|
-
continue;
|
|
133
|
-
}
|
|
134
|
-
for (let j = 0, len = encodedScanCodeCombos.length; j < len; j++) {
|
|
135
|
-
const entry = encodedScanCodeCombos[j];
|
|
136
|
-
const entryScanCode = (entry >>> 3);
|
|
137
|
-
if (entryScanCode === scanCode) {
|
|
138
|
-
for (let k = j + 1; k < len; k++) {
|
|
139
|
-
encodedScanCodeCombos[k - 1] = encodedScanCodeCombos[k];
|
|
140
|
-
}
|
|
141
|
-
encodedScanCodeCombos[len - 1] = entry;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
registerIfUnknown(scanCodeCombo, keyCodeCombo) {
|
|
148
|
-
if (keyCodeCombo.keyCode === 0 ) {
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
151
|
-
const scanCodeComboEncoded = this._encodeScanCodeCombo(scanCodeCombo);
|
|
152
|
-
const keyCodeComboEncoded = this._encodeKeyCodeCombo(keyCodeCombo);
|
|
153
|
-
const keyCodeIsDigit = ((keyCodeCombo.keyCode >= 21 && keyCodeCombo.keyCode <= 30) );
|
|
154
|
-
const keyCodeIsLetter = ((keyCodeCombo.keyCode >= 31 && keyCodeCombo.keyCode <= 56) );
|
|
155
|
-
const existingKeyCodeCombos = this._scanCodeToKeyCode[scanCodeComboEncoded];
|
|
156
|
-
if (keyCodeIsDigit || keyCodeIsLetter) {
|
|
157
|
-
if (existingKeyCodeCombos) {
|
|
158
|
-
for (let i = 0, len = existingKeyCodeCombos.length; i < len; i++) {
|
|
159
|
-
if (existingKeyCodeCombos[i] === keyCodeComboEncoded) {
|
|
160
|
-
return;
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
else {
|
|
166
|
-
if (existingKeyCodeCombos && existingKeyCodeCombos.length !== 0) {
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
this._scanCodeToKeyCode[scanCodeComboEncoded] = this._scanCodeToKeyCode[scanCodeComboEncoded] || [];
|
|
171
|
-
this._scanCodeToKeyCode[scanCodeComboEncoded].unshift(keyCodeComboEncoded);
|
|
172
|
-
this._keyCodeToScanCode[keyCodeComboEncoded] = this._keyCodeToScanCode[keyCodeComboEncoded] || [];
|
|
173
|
-
this._keyCodeToScanCode[keyCodeComboEncoded].unshift(scanCodeComboEncoded);
|
|
174
|
-
}
|
|
175
|
-
lookupKeyCodeCombo(keyCodeCombo) {
|
|
176
|
-
const keyCodeComboEncoded = this._encodeKeyCodeCombo(keyCodeCombo);
|
|
177
|
-
const scanCodeCombosEncoded = this._keyCodeToScanCode[keyCodeComboEncoded];
|
|
178
|
-
if (!scanCodeCombosEncoded || scanCodeCombosEncoded.length === 0) {
|
|
179
|
-
return [];
|
|
180
|
-
}
|
|
181
|
-
const result = [];
|
|
182
|
-
for (let i = 0, len = scanCodeCombosEncoded.length; i < len; i++) {
|
|
183
|
-
const scanCodeComboEncoded = scanCodeCombosEncoded[i];
|
|
184
|
-
const ctrlKey = (scanCodeComboEncoded & 0b001) ? true : false;
|
|
185
|
-
const shiftKey = (scanCodeComboEncoded & 0b010) ? true : false;
|
|
186
|
-
const altKey = (scanCodeComboEncoded & 0b100) ? true : false;
|
|
187
|
-
const scanCode = (scanCodeComboEncoded >>> 3);
|
|
188
|
-
result[i] = ( new ScanCodeCombo(ctrlKey, shiftKey, altKey, scanCode));
|
|
189
|
-
}
|
|
190
|
-
return result;
|
|
191
|
-
}
|
|
192
|
-
lookupScanCodeCombo(scanCodeCombo) {
|
|
193
|
-
const scanCodeComboEncoded = this._encodeScanCodeCombo(scanCodeCombo);
|
|
194
|
-
const keyCodeCombosEncoded = this._scanCodeToKeyCode[scanCodeComboEncoded];
|
|
195
|
-
if (!keyCodeCombosEncoded || keyCodeCombosEncoded.length === 0) {
|
|
196
|
-
return [];
|
|
197
|
-
}
|
|
198
|
-
const result = [];
|
|
199
|
-
for (let i = 0, len = keyCodeCombosEncoded.length; i < len; i++) {
|
|
200
|
-
const keyCodeComboEncoded = keyCodeCombosEncoded[i];
|
|
201
|
-
const ctrlKey = (keyCodeComboEncoded & 0b001) ? true : false;
|
|
202
|
-
const shiftKey = (keyCodeComboEncoded & 0b010) ? true : false;
|
|
203
|
-
const altKey = (keyCodeComboEncoded & 0b100) ? true : false;
|
|
204
|
-
const keyCode = (keyCodeComboEncoded >>> 3);
|
|
205
|
-
result[i] = ( new KeyCodeCombo(ctrlKey, shiftKey, altKey, keyCode));
|
|
206
|
-
}
|
|
207
|
-
return result;
|
|
208
|
-
}
|
|
209
|
-
guessStableKeyCode(scanCode) {
|
|
210
|
-
if (scanCode >= 36 && scanCode <= 45 ) {
|
|
211
|
-
switch (scanCode) {
|
|
212
|
-
case 36 : return 22 ;
|
|
213
|
-
case 37 : return 23 ;
|
|
214
|
-
case 38 : return 24 ;
|
|
215
|
-
case 39 : return 25 ;
|
|
216
|
-
case 40 : return 26 ;
|
|
217
|
-
case 41 : return 27 ;
|
|
218
|
-
case 42 : return 28 ;
|
|
219
|
-
case 43 : return 29 ;
|
|
220
|
-
case 44 : return 30 ;
|
|
221
|
-
case 45 : return 21 ;
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
const keyCodeCombos1 = this.lookupScanCodeCombo(( new ScanCodeCombo(false, false, false, scanCode)));
|
|
225
|
-
const keyCodeCombos2 = this.lookupScanCodeCombo(( new ScanCodeCombo(false, true, false, scanCode)));
|
|
226
|
-
if (keyCodeCombos1.length === 1 && keyCodeCombos2.length === 1) {
|
|
227
|
-
const shiftKey1 = keyCodeCombos1[0].shiftKey;
|
|
228
|
-
const keyCode1 = keyCodeCombos1[0].keyCode;
|
|
229
|
-
const shiftKey2 = keyCodeCombos2[0].shiftKey;
|
|
230
|
-
const keyCode2 = keyCodeCombos2[0].keyCode;
|
|
231
|
-
if (keyCode1 === keyCode2 && shiftKey1 !== shiftKey2) {
|
|
232
|
-
return keyCode1;
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
return -1 ;
|
|
236
|
-
}
|
|
237
|
-
_encodeScanCodeCombo(scanCodeCombo) {
|
|
238
|
-
return this._encode(scanCodeCombo.ctrlKey, scanCodeCombo.shiftKey, scanCodeCombo.altKey, scanCodeCombo.scanCode);
|
|
239
|
-
}
|
|
240
|
-
_encodeKeyCodeCombo(keyCodeCombo) {
|
|
241
|
-
return this._encode(keyCodeCombo.ctrlKey, keyCodeCombo.shiftKey, keyCodeCombo.altKey, keyCodeCombo.keyCode);
|
|
242
|
-
}
|
|
243
|
-
_encode(ctrlKey, shiftKey, altKey, principal) {
|
|
244
|
-
return (((ctrlKey ? 1 : 0) << 0)
|
|
245
|
-
| ((shiftKey ? 1 : 0) << 1)
|
|
246
|
-
| ((altKey ? 1 : 0) << 2)
|
|
247
|
-
| principal << 3) >>> 0;
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
class MacLinuxKeyboardMapper {
|
|
251
|
-
constructor(_isUSStandard, rawMappings, _mapAltGrToCtrlAlt, _OS) {
|
|
252
|
-
this._isUSStandard = _isUSStandard;
|
|
253
|
-
this._mapAltGrToCtrlAlt = _mapAltGrToCtrlAlt;
|
|
254
|
-
this._OS = _OS;
|
|
255
|
-
this._scanCodeToLabel = [];
|
|
256
|
-
this._scanCodeToDispatch = [];
|
|
257
|
-
this._codeInfo = [];
|
|
258
|
-
this._scanCodeKeyCodeMapper = ( new ScanCodeKeyCodeMapper());
|
|
259
|
-
this._scanCodeToLabel = [];
|
|
260
|
-
this._scanCodeToDispatch = [];
|
|
261
|
-
const _registerIfUnknown = (hwCtrlKey, hwShiftKey, hwAltKey, scanCode, kbCtrlKey, kbShiftKey, kbAltKey, keyCode) => {
|
|
262
|
-
this._scanCodeKeyCodeMapper.registerIfUnknown(( new ScanCodeCombo(
|
|
263
|
-
hwCtrlKey ? true : false,
|
|
264
|
-
hwShiftKey ? true : false,
|
|
265
|
-
hwAltKey ? true : false,
|
|
266
|
-
scanCode
|
|
267
|
-
)), ( new KeyCodeCombo(
|
|
268
|
-
kbCtrlKey ? true : false,
|
|
269
|
-
kbShiftKey ? true : false,
|
|
270
|
-
kbAltKey ? true : false,
|
|
271
|
-
keyCode
|
|
272
|
-
)));
|
|
273
|
-
};
|
|
274
|
-
const _registerAllCombos = (_ctrlKey, _shiftKey, _altKey, scanCode, keyCode) => {
|
|
275
|
-
for (let ctrlKey = _ctrlKey; ctrlKey <= 1; ctrlKey++) {
|
|
276
|
-
for (let shiftKey = _shiftKey; shiftKey <= 1; shiftKey++) {
|
|
277
|
-
for (let altKey = _altKey; altKey <= 1; altKey++) {
|
|
278
|
-
_registerIfUnknown(ctrlKey, shiftKey, altKey, scanCode, ctrlKey, shiftKey, altKey, keyCode);
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
};
|
|
283
|
-
for (let scanCode = 0 ; scanCode < 193 ; scanCode++) {
|
|
284
|
-
this._scanCodeToLabel[scanCode] = null;
|
|
285
|
-
}
|
|
286
|
-
for (let scanCode = 0 ; scanCode < 193 ; scanCode++) {
|
|
287
|
-
this._scanCodeToDispatch[scanCode] = null;
|
|
288
|
-
}
|
|
289
|
-
for (let scanCode = 0 ; scanCode < 193 ; scanCode++) {
|
|
290
|
-
const keyCode = IMMUTABLE_CODE_TO_KEY_CODE[scanCode];
|
|
291
|
-
if (keyCode !== -1 ) {
|
|
292
|
-
_registerAllCombos(0, 0, 0, scanCode, keyCode);
|
|
293
|
-
this._scanCodeToLabel[scanCode] = ( KeyCodeUtils.toString(keyCode));
|
|
294
|
-
if (keyCode === 0 || keyCode === 5 || keyCode === 57 || keyCode === 6 || keyCode === 4 ) {
|
|
295
|
-
this._scanCodeToDispatch[scanCode] = null;
|
|
296
|
-
}
|
|
297
|
-
else {
|
|
298
|
-
this._scanCodeToDispatch[scanCode] = `[${( ScanCodeUtils.toString(scanCode))}]`;
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
const missingLatinLettersOverride = {};
|
|
303
|
-
{
|
|
304
|
-
const producesLatinLetter = [];
|
|
305
|
-
for (const strScanCode in rawMappings) {
|
|
306
|
-
if (rawMappings.hasOwnProperty(strScanCode)) {
|
|
307
|
-
const scanCode = ScanCodeUtils.toEnum(strScanCode);
|
|
308
|
-
if (scanCode === 0 ) {
|
|
309
|
-
continue;
|
|
310
|
-
}
|
|
311
|
-
if (IMMUTABLE_CODE_TO_KEY_CODE[scanCode] !== -1 ) {
|
|
312
|
-
continue;
|
|
313
|
-
}
|
|
314
|
-
const rawMapping = rawMappings[strScanCode];
|
|
315
|
-
const value = MacLinuxKeyboardMapper.getCharCode(rawMapping.value);
|
|
316
|
-
if (value >= 97 && value <= 122 ) {
|
|
317
|
-
const upperCaseValue = 65 + ((value - 97) );
|
|
318
|
-
producesLatinLetter[upperCaseValue] = true;
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
const _registerLetterIfMissing = (charCode, scanCode, value, withShift) => {
|
|
323
|
-
if (!producesLatinLetter[charCode]) {
|
|
324
|
-
missingLatinLettersOverride[( ScanCodeUtils.toString(scanCode))] = {
|
|
325
|
-
value: value,
|
|
326
|
-
withShift: withShift,
|
|
327
|
-
withAltGr: '',
|
|
328
|
-
withShiftAltGr: ''
|
|
329
|
-
};
|
|
330
|
-
}
|
|
331
|
-
};
|
|
332
|
-
_registerLetterIfMissing(65 , 10 , 'a', 'A');
|
|
333
|
-
_registerLetterIfMissing(66 , 11 , 'b', 'B');
|
|
334
|
-
_registerLetterIfMissing(67 , 12 , 'c', 'C');
|
|
335
|
-
_registerLetterIfMissing(68 , 13 , 'd', 'D');
|
|
336
|
-
_registerLetterIfMissing(69 , 14 , 'e', 'E');
|
|
337
|
-
_registerLetterIfMissing(70 , 15 , 'f', 'F');
|
|
338
|
-
_registerLetterIfMissing(71 , 16 , 'g', 'G');
|
|
339
|
-
_registerLetterIfMissing(72 , 17 , 'h', 'H');
|
|
340
|
-
_registerLetterIfMissing(73 , 18 , 'i', 'I');
|
|
341
|
-
_registerLetterIfMissing(74 , 19 , 'j', 'J');
|
|
342
|
-
_registerLetterIfMissing(75 , 20 , 'k', 'K');
|
|
343
|
-
_registerLetterIfMissing(76 , 21 , 'l', 'L');
|
|
344
|
-
_registerLetterIfMissing(77 , 22 , 'm', 'M');
|
|
345
|
-
_registerLetterIfMissing(78 , 23 , 'n', 'N');
|
|
346
|
-
_registerLetterIfMissing(79 , 24 , 'o', 'O');
|
|
347
|
-
_registerLetterIfMissing(80 , 25 , 'p', 'P');
|
|
348
|
-
_registerLetterIfMissing(81 , 26 , 'q', 'Q');
|
|
349
|
-
_registerLetterIfMissing(82 , 27 , 'r', 'R');
|
|
350
|
-
_registerLetterIfMissing(83 , 28 , 's', 'S');
|
|
351
|
-
_registerLetterIfMissing(84 , 29 , 't', 'T');
|
|
352
|
-
_registerLetterIfMissing(85 , 30 , 'u', 'U');
|
|
353
|
-
_registerLetterIfMissing(86 , 31 , 'v', 'V');
|
|
354
|
-
_registerLetterIfMissing(87 , 32 , 'w', 'W');
|
|
355
|
-
_registerLetterIfMissing(88 , 33 , 'x', 'X');
|
|
356
|
-
_registerLetterIfMissing(89 , 34 , 'y', 'Y');
|
|
357
|
-
_registerLetterIfMissing(90 , 35 , 'z', 'Z');
|
|
358
|
-
}
|
|
359
|
-
const mappings = [];
|
|
360
|
-
let mappingsLen = 0;
|
|
361
|
-
for (const strScanCode in rawMappings) {
|
|
362
|
-
if (rawMappings.hasOwnProperty(strScanCode)) {
|
|
363
|
-
const scanCode = ScanCodeUtils.toEnum(strScanCode);
|
|
364
|
-
if (scanCode === 0 ) {
|
|
365
|
-
continue;
|
|
366
|
-
}
|
|
367
|
-
if (IMMUTABLE_CODE_TO_KEY_CODE[scanCode] !== -1 ) {
|
|
368
|
-
continue;
|
|
369
|
-
}
|
|
370
|
-
this._codeInfo[scanCode] = rawMappings[strScanCode];
|
|
371
|
-
const rawMapping = missingLatinLettersOverride[strScanCode] || rawMappings[strScanCode];
|
|
372
|
-
const value = MacLinuxKeyboardMapper.getCharCode(rawMapping.value);
|
|
373
|
-
const withShift = MacLinuxKeyboardMapper.getCharCode(rawMapping.withShift);
|
|
374
|
-
const withAltGr = MacLinuxKeyboardMapper.getCharCode(rawMapping.withAltGr);
|
|
375
|
-
const withShiftAltGr = MacLinuxKeyboardMapper.getCharCode(rawMapping.withShiftAltGr);
|
|
376
|
-
const mapping = {
|
|
377
|
-
scanCode: scanCode,
|
|
378
|
-
value: value,
|
|
379
|
-
withShift: withShift,
|
|
380
|
-
withAltGr: withAltGr,
|
|
381
|
-
withShiftAltGr: withShiftAltGr,
|
|
382
|
-
};
|
|
383
|
-
mappings[mappingsLen++] = mapping;
|
|
384
|
-
this._scanCodeToDispatch[scanCode] = `[${( ScanCodeUtils.toString(scanCode))}]`;
|
|
385
|
-
if (value >= 97 && value <= 122 ) {
|
|
386
|
-
const upperCaseValue = 65 + ((value - 97) );
|
|
387
|
-
this._scanCodeToLabel[scanCode] = String.fromCharCode(upperCaseValue);
|
|
388
|
-
}
|
|
389
|
-
else if (value >= 65 && value <= 90 ) {
|
|
390
|
-
this._scanCodeToLabel[scanCode] = String.fromCharCode(value);
|
|
391
|
-
}
|
|
392
|
-
else if (value) {
|
|
393
|
-
this._scanCodeToLabel[scanCode] = String.fromCharCode(value);
|
|
394
|
-
}
|
|
395
|
-
else {
|
|
396
|
-
this._scanCodeToLabel[scanCode] = null;
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
for (let i = mappings.length - 1; i >= 0; i--) {
|
|
401
|
-
const mapping = mappings[i];
|
|
402
|
-
const scanCode = mapping.scanCode;
|
|
403
|
-
const withShiftAltGr = mapping.withShiftAltGr;
|
|
404
|
-
if (withShiftAltGr === mapping.withAltGr || withShiftAltGr === mapping.withShift || withShiftAltGr === mapping.value) {
|
|
405
|
-
continue;
|
|
406
|
-
}
|
|
407
|
-
const kb = MacLinuxKeyboardMapper._charCodeToKb(withShiftAltGr);
|
|
408
|
-
if (!kb) {
|
|
409
|
-
continue;
|
|
410
|
-
}
|
|
411
|
-
const kbShiftKey = kb.shiftKey;
|
|
412
|
-
const keyCode = kb.keyCode;
|
|
413
|
-
if (kbShiftKey) {
|
|
414
|
-
_registerIfUnknown(1, 1, 1, scanCode, 0, 1, 0, keyCode);
|
|
415
|
-
}
|
|
416
|
-
else {
|
|
417
|
-
_registerIfUnknown(1, 1, 1, scanCode, 0, 0, 0, keyCode);
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
for (let i = mappings.length - 1; i >= 0; i--) {
|
|
421
|
-
const mapping = mappings[i];
|
|
422
|
-
const scanCode = mapping.scanCode;
|
|
423
|
-
const withAltGr = mapping.withAltGr;
|
|
424
|
-
if (withAltGr === mapping.withShift || withAltGr === mapping.value) {
|
|
425
|
-
continue;
|
|
426
|
-
}
|
|
427
|
-
const kb = MacLinuxKeyboardMapper._charCodeToKb(withAltGr);
|
|
428
|
-
if (!kb) {
|
|
429
|
-
continue;
|
|
430
|
-
}
|
|
431
|
-
const kbShiftKey = kb.shiftKey;
|
|
432
|
-
const keyCode = kb.keyCode;
|
|
433
|
-
if (kbShiftKey) {
|
|
434
|
-
_registerIfUnknown(1, 0, 1, scanCode, 0, 1, 0, keyCode);
|
|
435
|
-
}
|
|
436
|
-
else {
|
|
437
|
-
_registerIfUnknown(1, 0, 1, scanCode, 0, 0, 0, keyCode);
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
|
-
for (let i = mappings.length - 1; i >= 0; i--) {
|
|
441
|
-
const mapping = mappings[i];
|
|
442
|
-
const scanCode = mapping.scanCode;
|
|
443
|
-
const withShift = mapping.withShift;
|
|
444
|
-
if (withShift === mapping.value) {
|
|
445
|
-
continue;
|
|
446
|
-
}
|
|
447
|
-
const kb = MacLinuxKeyboardMapper._charCodeToKb(withShift);
|
|
448
|
-
if (!kb) {
|
|
449
|
-
continue;
|
|
450
|
-
}
|
|
451
|
-
const kbShiftKey = kb.shiftKey;
|
|
452
|
-
const keyCode = kb.keyCode;
|
|
453
|
-
if (kbShiftKey) {
|
|
454
|
-
_registerIfUnknown(0, 1, 0, scanCode, 0, 1, 0, keyCode);
|
|
455
|
-
_registerIfUnknown(0, 1, 1, scanCode, 0, 1, 1, keyCode);
|
|
456
|
-
_registerIfUnknown(1, 1, 0, scanCode, 1, 1, 0, keyCode);
|
|
457
|
-
_registerIfUnknown(1, 1, 1, scanCode, 1, 1, 1, keyCode);
|
|
458
|
-
}
|
|
459
|
-
else {
|
|
460
|
-
_registerIfUnknown(0, 1, 0, scanCode, 0, 0, 0, keyCode);
|
|
461
|
-
_registerIfUnknown(0, 1, 0, scanCode, 0, 1, 0, keyCode);
|
|
462
|
-
_registerIfUnknown(0, 1, 1, scanCode, 0, 0, 1, keyCode);
|
|
463
|
-
_registerIfUnknown(0, 1, 1, scanCode, 0, 1, 1, keyCode);
|
|
464
|
-
_registerIfUnknown(1, 1, 0, scanCode, 1, 0, 0, keyCode);
|
|
465
|
-
_registerIfUnknown(1, 1, 0, scanCode, 1, 1, 0, keyCode);
|
|
466
|
-
_registerIfUnknown(1, 1, 1, scanCode, 1, 0, 1, keyCode);
|
|
467
|
-
_registerIfUnknown(1, 1, 1, scanCode, 1, 1, 1, keyCode);
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
for (let i = mappings.length - 1; i >= 0; i--) {
|
|
471
|
-
const mapping = mappings[i];
|
|
472
|
-
const scanCode = mapping.scanCode;
|
|
473
|
-
const kb = MacLinuxKeyboardMapper._charCodeToKb(mapping.value);
|
|
474
|
-
if (!kb) {
|
|
475
|
-
continue;
|
|
476
|
-
}
|
|
477
|
-
const kbShiftKey = kb.shiftKey;
|
|
478
|
-
const keyCode = kb.keyCode;
|
|
479
|
-
if (kbShiftKey) {
|
|
480
|
-
_registerIfUnknown(0, 0, 0, scanCode, 0, 1, 0, keyCode);
|
|
481
|
-
_registerIfUnknown(0, 0, 1, scanCode, 0, 1, 1, keyCode);
|
|
482
|
-
_registerIfUnknown(1, 0, 0, scanCode, 1, 1, 0, keyCode);
|
|
483
|
-
_registerIfUnknown(1, 0, 1, scanCode, 1, 1, 1, keyCode);
|
|
484
|
-
}
|
|
485
|
-
else {
|
|
486
|
-
_registerIfUnknown(0, 0, 0, scanCode, 0, 0, 0, keyCode);
|
|
487
|
-
_registerIfUnknown(0, 0, 1, scanCode, 0, 0, 1, keyCode);
|
|
488
|
-
_registerIfUnknown(0, 1, 0, scanCode, 0, 1, 0, keyCode);
|
|
489
|
-
_registerIfUnknown(0, 1, 1, scanCode, 0, 1, 1, keyCode);
|
|
490
|
-
_registerIfUnknown(1, 0, 0, scanCode, 1, 0, 0, keyCode);
|
|
491
|
-
_registerIfUnknown(1, 0, 1, scanCode, 1, 0, 1, keyCode);
|
|
492
|
-
_registerIfUnknown(1, 1, 0, scanCode, 1, 1, 0, keyCode);
|
|
493
|
-
_registerIfUnknown(1, 1, 1, scanCode, 1, 1, 1, keyCode);
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
|
-
_registerAllCombos(0, 0, 0, 36 , 22 );
|
|
497
|
-
_registerAllCombos(0, 0, 0, 37 , 23 );
|
|
498
|
-
_registerAllCombos(0, 0, 0, 38 , 24 );
|
|
499
|
-
_registerAllCombos(0, 0, 0, 39 , 25 );
|
|
500
|
-
_registerAllCombos(0, 0, 0, 40 , 26 );
|
|
501
|
-
_registerAllCombos(0, 0, 0, 41 , 27 );
|
|
502
|
-
_registerAllCombos(0, 0, 0, 42 , 28 );
|
|
503
|
-
_registerAllCombos(0, 0, 0, 43 , 29 );
|
|
504
|
-
_registerAllCombos(0, 0, 0, 44 , 30 );
|
|
505
|
-
_registerAllCombos(0, 0, 0, 45 , 21 );
|
|
506
|
-
this._scanCodeKeyCodeMapper.registrationComplete();
|
|
507
|
-
}
|
|
508
|
-
dumpDebugInfo() {
|
|
509
|
-
const result = [];
|
|
510
|
-
const immutableSamples = [
|
|
511
|
-
88 ,
|
|
512
|
-
104
|
|
513
|
-
];
|
|
514
|
-
let cnt = 0;
|
|
515
|
-
result.push(`isUSStandard: ${this._isUSStandard}`);
|
|
516
|
-
result.push(`----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------`);
|
|
517
|
-
for (let scanCode = 0 ; scanCode < 193 ; scanCode++) {
|
|
518
|
-
if (IMMUTABLE_CODE_TO_KEY_CODE[scanCode] !== -1 ) {
|
|
519
|
-
if (immutableSamples.indexOf(scanCode) === -1) {
|
|
520
|
-
continue;
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
if (cnt % 4 === 0) {
|
|
524
|
-
result.push(`| HW Code combination | Key | KeyCode combination | Pri | UI label | User settings | Electron accelerator | Dispatching string | WYSIWYG |`);
|
|
525
|
-
result.push(`----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------`);
|
|
526
|
-
}
|
|
527
|
-
cnt++;
|
|
528
|
-
const mapping = this._codeInfo[scanCode];
|
|
529
|
-
for (let mod = 0; mod < 8; mod++) {
|
|
530
|
-
const hwCtrlKey = (mod & 0b001) ? true : false;
|
|
531
|
-
const hwShiftKey = (mod & 0b010) ? true : false;
|
|
532
|
-
const hwAltKey = (mod & 0b100) ? true : false;
|
|
533
|
-
const scanCodeCombo = ( new ScanCodeCombo(hwCtrlKey, hwShiftKey, hwAltKey, scanCode));
|
|
534
|
-
const resolvedKb = this.resolveKeyboardEvent({
|
|
535
|
-
_standardKeyboardEventBrand: true,
|
|
536
|
-
ctrlKey: scanCodeCombo.ctrlKey,
|
|
537
|
-
shiftKey: scanCodeCombo.shiftKey,
|
|
538
|
-
altKey: scanCodeCombo.altKey,
|
|
539
|
-
metaKey: false,
|
|
540
|
-
altGraphKey: false,
|
|
541
|
-
keyCode: -1 ,
|
|
542
|
-
code: ( ScanCodeUtils.toString(scanCode))
|
|
543
|
-
});
|
|
544
|
-
const outScanCodeCombo = ( scanCodeCombo.toString());
|
|
545
|
-
const outKey = scanCodeCombo.getProducedChar(mapping);
|
|
546
|
-
const ariaLabel = resolvedKb.getAriaLabel();
|
|
547
|
-
const outUILabel = (ariaLabel ? ariaLabel.replace(/Control\+/, 'Ctrl+') : null);
|
|
548
|
-
const outUserSettings = resolvedKb.getUserSettingsLabel();
|
|
549
|
-
const outElectronAccelerator = resolvedKb.getElectronAccelerator();
|
|
550
|
-
const outDispatchStr = resolvedKb.getDispatchChords()[0];
|
|
551
|
-
const isWYSIWYG = (resolvedKb ? resolvedKb.isWYSIWYG() : false);
|
|
552
|
-
const outWYSIWYG = (isWYSIWYG ? ' ' : ' NO ');
|
|
553
|
-
const kbCombos = this._scanCodeKeyCodeMapper.lookupScanCodeCombo(scanCodeCombo);
|
|
554
|
-
if (kbCombos.length === 0) {
|
|
555
|
-
result.push(`| ${this._leftPad(outScanCodeCombo, 30)} | ${outKey} | ${this._leftPad('', 25)} | ${this._leftPad('', 3)} | ${this._leftPad(outUILabel, 25)} | ${this._leftPad(outUserSettings, 30)} | ${this._leftPad(outElectronAccelerator, 25)} | ${this._leftPad(outDispatchStr, 30)} | ${outWYSIWYG} |`);
|
|
556
|
-
}
|
|
557
|
-
else {
|
|
558
|
-
for (let i = 0, len = kbCombos.length; i < len; i++) {
|
|
559
|
-
const kbCombo = kbCombos[i];
|
|
560
|
-
let colPriority;
|
|
561
|
-
const scanCodeCombos = this._scanCodeKeyCodeMapper.lookupKeyCodeCombo(kbCombo);
|
|
562
|
-
if (scanCodeCombos.length === 1) {
|
|
563
|
-
colPriority = '';
|
|
564
|
-
}
|
|
565
|
-
else {
|
|
566
|
-
let priority = -1;
|
|
567
|
-
for (let j = 0; j < scanCodeCombos.length; j++) {
|
|
568
|
-
if (scanCodeCombos[j].equals(scanCodeCombo)) {
|
|
569
|
-
priority = j + 1;
|
|
570
|
-
break;
|
|
571
|
-
}
|
|
572
|
-
}
|
|
573
|
-
colPriority = String(priority);
|
|
574
|
-
}
|
|
575
|
-
const outKeybinding = ( kbCombo.toString());
|
|
576
|
-
if (i === 0) {
|
|
577
|
-
result.push(`| ${this._leftPad(outScanCodeCombo, 30)} | ${outKey} | ${this._leftPad(outKeybinding, 25)} | ${this._leftPad(colPriority, 3)} | ${this._leftPad(outUILabel, 25)} | ${this._leftPad(outUserSettings, 30)} | ${this._leftPad(outElectronAccelerator, 25)} | ${this._leftPad(outDispatchStr, 30)} | ${outWYSIWYG} |`);
|
|
578
|
-
}
|
|
579
|
-
else {
|
|
580
|
-
result.push(`| ${this._leftPad('', 30)} | | ${this._leftPad(outKeybinding, 25)} | ${this._leftPad(colPriority, 3)} | ${this._leftPad('', 25)} | ${this._leftPad('', 30)} | ${this._leftPad('', 25)} | ${this._leftPad('', 30)} | |`);
|
|
581
|
-
}
|
|
582
|
-
}
|
|
583
|
-
}
|
|
584
|
-
}
|
|
585
|
-
result.push(`----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------`);
|
|
586
|
-
}
|
|
587
|
-
return result.join('\n');
|
|
588
|
-
}
|
|
589
|
-
_leftPad(str, cnt) {
|
|
590
|
-
if (str === null) {
|
|
591
|
-
str = 'null';
|
|
592
|
-
}
|
|
593
|
-
while (str.length < cnt) {
|
|
594
|
-
str = ' ' + str;
|
|
595
|
-
}
|
|
596
|
-
return str;
|
|
597
|
-
}
|
|
598
|
-
keyCodeChordToScanCodeChord(chord) {
|
|
599
|
-
if (chord.keyCode === 3 ) {
|
|
600
|
-
return [( new ScanCodeChord(
|
|
601
|
-
chord.ctrlKey,
|
|
602
|
-
chord.shiftKey,
|
|
603
|
-
chord.altKey,
|
|
604
|
-
chord.metaKey,
|
|
605
|
-
46
|
|
606
|
-
))];
|
|
607
|
-
}
|
|
608
|
-
const scanCodeCombos = this._scanCodeKeyCodeMapper.lookupKeyCodeCombo(( new KeyCodeCombo(chord.ctrlKey, chord.shiftKey, chord.altKey, chord.keyCode)));
|
|
609
|
-
const result = [];
|
|
610
|
-
for (let i = 0, len = scanCodeCombos.length; i < len; i++) {
|
|
611
|
-
const scanCodeCombo = scanCodeCombos[i];
|
|
612
|
-
result[i] = ( new ScanCodeChord(
|
|
613
|
-
scanCodeCombo.ctrlKey,
|
|
614
|
-
scanCodeCombo.shiftKey,
|
|
615
|
-
scanCodeCombo.altKey,
|
|
616
|
-
chord.metaKey,
|
|
617
|
-
scanCodeCombo.scanCode
|
|
618
|
-
));
|
|
619
|
-
}
|
|
620
|
-
return result;
|
|
621
|
-
}
|
|
622
|
-
getUILabelForScanCodeChord(chord) {
|
|
623
|
-
if (!chord) {
|
|
624
|
-
return null;
|
|
625
|
-
}
|
|
626
|
-
if (chord.isDuplicateModifierCase()) {
|
|
627
|
-
return '';
|
|
628
|
-
}
|
|
629
|
-
if (this._OS === 2 ) {
|
|
630
|
-
switch (chord.scanCode) {
|
|
631
|
-
case 86 :
|
|
632
|
-
return '←';
|
|
633
|
-
case 88 :
|
|
634
|
-
return '↑';
|
|
635
|
-
case 85 :
|
|
636
|
-
return '→';
|
|
637
|
-
case 87 :
|
|
638
|
-
return '↓';
|
|
639
|
-
}
|
|
640
|
-
}
|
|
641
|
-
return this._scanCodeToLabel[chord.scanCode];
|
|
642
|
-
}
|
|
643
|
-
getAriaLabelForScanCodeChord(chord) {
|
|
644
|
-
if (!chord) {
|
|
645
|
-
return null;
|
|
646
|
-
}
|
|
647
|
-
if (chord.isDuplicateModifierCase()) {
|
|
648
|
-
return '';
|
|
649
|
-
}
|
|
650
|
-
return this._scanCodeToLabel[chord.scanCode];
|
|
651
|
-
}
|
|
652
|
-
getDispatchStrForScanCodeChord(chord) {
|
|
653
|
-
const codeDispatch = this._scanCodeToDispatch[chord.scanCode];
|
|
654
|
-
if (!codeDispatch) {
|
|
655
|
-
return null;
|
|
656
|
-
}
|
|
657
|
-
let result = '';
|
|
658
|
-
if (chord.ctrlKey) {
|
|
659
|
-
result += 'ctrl+';
|
|
660
|
-
}
|
|
661
|
-
if (chord.shiftKey) {
|
|
662
|
-
result += 'shift+';
|
|
663
|
-
}
|
|
664
|
-
if (chord.altKey) {
|
|
665
|
-
result += 'alt+';
|
|
666
|
-
}
|
|
667
|
-
if (chord.metaKey) {
|
|
668
|
-
result += 'meta+';
|
|
669
|
-
}
|
|
670
|
-
result += codeDispatch;
|
|
671
|
-
return result;
|
|
672
|
-
}
|
|
673
|
-
getUserSettingsLabelForScanCodeChord(chord) {
|
|
674
|
-
if (!chord) {
|
|
675
|
-
return null;
|
|
676
|
-
}
|
|
677
|
-
if (chord.isDuplicateModifierCase()) {
|
|
678
|
-
return '';
|
|
679
|
-
}
|
|
680
|
-
const immutableKeyCode = IMMUTABLE_CODE_TO_KEY_CODE[chord.scanCode];
|
|
681
|
-
if (immutableKeyCode !== -1 ) {
|
|
682
|
-
return KeyCodeUtils.toUserSettingsUS(immutableKeyCode).toLowerCase();
|
|
683
|
-
}
|
|
684
|
-
const constantKeyCode = this._scanCodeKeyCodeMapper.guessStableKeyCode(chord.scanCode);
|
|
685
|
-
if (constantKeyCode !== -1 ) {
|
|
686
|
-
const reverseChords = this.keyCodeChordToScanCodeChord(( new KeyCodeChord(
|
|
687
|
-
chord.ctrlKey,
|
|
688
|
-
chord.shiftKey,
|
|
689
|
-
chord.altKey,
|
|
690
|
-
chord.metaKey,
|
|
691
|
-
constantKeyCode
|
|
692
|
-
)));
|
|
693
|
-
for (let i = 0, len = reverseChords.length; i < len; i++) {
|
|
694
|
-
const reverseChord = reverseChords[i];
|
|
695
|
-
if (reverseChord.scanCode === chord.scanCode) {
|
|
696
|
-
return KeyCodeUtils.toUserSettingsUS(constantKeyCode).toLowerCase();
|
|
697
|
-
}
|
|
698
|
-
}
|
|
699
|
-
}
|
|
700
|
-
return this._scanCodeToDispatch[chord.scanCode];
|
|
701
|
-
}
|
|
702
|
-
getElectronAcceleratorLabelForScanCodeChord(chord) {
|
|
703
|
-
if (!chord) {
|
|
704
|
-
return null;
|
|
705
|
-
}
|
|
706
|
-
const immutableKeyCode = IMMUTABLE_CODE_TO_KEY_CODE[chord.scanCode];
|
|
707
|
-
if (immutableKeyCode !== -1 ) {
|
|
708
|
-
return KeyCodeUtils.toElectronAccelerator(immutableKeyCode);
|
|
709
|
-
}
|
|
710
|
-
const constantKeyCode = this._scanCodeKeyCodeMapper.guessStableKeyCode(chord.scanCode);
|
|
711
|
-
if (this._OS === 3 && !this._isUSStandard) {
|
|
712
|
-
const isOEMKey = ((constantKeyCode === 85
|
|
713
|
-
|| constantKeyCode === 86
|
|
714
|
-
|| constantKeyCode === 87
|
|
715
|
-
|| constantKeyCode === 88
|
|
716
|
-
|| constantKeyCode === 89
|
|
717
|
-
|| constantKeyCode === 90
|
|
718
|
-
|| constantKeyCode === 91
|
|
719
|
-
|| constantKeyCode === 92
|
|
720
|
-
|| constantKeyCode === 93 || constantKeyCode === 94) );
|
|
721
|
-
if (isOEMKey) {
|
|
722
|
-
return null;
|
|
723
|
-
}
|
|
724
|
-
}
|
|
725
|
-
if (constantKeyCode !== -1 ) {
|
|
726
|
-
return KeyCodeUtils.toElectronAccelerator(constantKeyCode);
|
|
727
|
-
}
|
|
728
|
-
return null;
|
|
729
|
-
}
|
|
730
|
-
_toResolvedKeybinding(chordParts) {
|
|
731
|
-
if (chordParts.length === 0) {
|
|
732
|
-
return [];
|
|
733
|
-
}
|
|
734
|
-
const result = [];
|
|
735
|
-
this._generateResolvedKeybindings(chordParts, 0, [], result);
|
|
736
|
-
return result;
|
|
737
|
-
}
|
|
738
|
-
_generateResolvedKeybindings(chordParts, currentIndex, previousParts, result) {
|
|
739
|
-
const chordPart = chordParts[currentIndex];
|
|
740
|
-
const isFinalIndex = currentIndex === chordParts.length - 1;
|
|
741
|
-
for (let i = 0, len = chordPart.length; i < len; i++) {
|
|
742
|
-
const chords = [...previousParts, chordPart[i]];
|
|
743
|
-
if (isFinalIndex) {
|
|
744
|
-
result.push(( new NativeResolvedKeybinding(this, this._OS, chords)));
|
|
745
|
-
}
|
|
746
|
-
else {
|
|
747
|
-
this._generateResolvedKeybindings(chordParts, currentIndex + 1, chords, result);
|
|
748
|
-
}
|
|
749
|
-
}
|
|
750
|
-
}
|
|
751
|
-
resolveKeyboardEvent(keyboardEvent) {
|
|
752
|
-
let code = ScanCodeUtils.toEnum(keyboardEvent.code);
|
|
753
|
-
if (code === 94 ) {
|
|
754
|
-
code = 46 ;
|
|
755
|
-
}
|
|
756
|
-
const keyCode = keyboardEvent.keyCode;
|
|
757
|
-
if (((keyCode === 15) )
|
|
758
|
-
|| ((keyCode === 16) )
|
|
759
|
-
|| ((keyCode === 17) )
|
|
760
|
-
|| ((keyCode === 18) )
|
|
761
|
-
|| ((keyCode === 20) )
|
|
762
|
-
|| ((keyCode === 19) )
|
|
763
|
-
|| ((keyCode === 14) )
|
|
764
|
-
|| ((keyCode === 13) )
|
|
765
|
-
|| ((keyCode === 12) )
|
|
766
|
-
|| ((keyCode === 11) )
|
|
767
|
-
|| ((keyCode === 1) )) {
|
|
768
|
-
const immutableScanCode = IMMUTABLE_KEY_CODE_TO_CODE[keyCode];
|
|
769
|
-
if (immutableScanCode !== -1 ) {
|
|
770
|
-
code = immutableScanCode;
|
|
771
|
-
}
|
|
772
|
-
}
|
|
773
|
-
else {
|
|
774
|
-
if (((code === 95) )
|
|
775
|
-
|| ((code === 96) )
|
|
776
|
-
|| ((code === 97) )
|
|
777
|
-
|| ((code === 98) )
|
|
778
|
-
|| ((code === 99) )
|
|
779
|
-
|| ((code === 100) )
|
|
780
|
-
|| ((code === 101) )
|
|
781
|
-
|| ((code === 102) )
|
|
782
|
-
|| ((code === 103) )
|
|
783
|
-
|| ((code === 104) )
|
|
784
|
-
|| ((code === 105) )) {
|
|
785
|
-
if (keyCode >= 0) {
|
|
786
|
-
const immutableScanCode = IMMUTABLE_KEY_CODE_TO_CODE[keyCode];
|
|
787
|
-
if (immutableScanCode !== -1 ) {
|
|
788
|
-
code = immutableScanCode;
|
|
789
|
-
}
|
|
790
|
-
}
|
|
791
|
-
}
|
|
792
|
-
}
|
|
793
|
-
const ctrlKey = keyboardEvent.ctrlKey || (this._mapAltGrToCtrlAlt && keyboardEvent.altGraphKey);
|
|
794
|
-
const altKey = keyboardEvent.altKey || (this._mapAltGrToCtrlAlt && keyboardEvent.altGraphKey);
|
|
795
|
-
const chord = ( new ScanCodeChord(ctrlKey, keyboardEvent.shiftKey, altKey, keyboardEvent.metaKey, code));
|
|
796
|
-
return ( new NativeResolvedKeybinding(this, this._OS, [chord]));
|
|
797
|
-
}
|
|
798
|
-
_resolveChord(chord) {
|
|
799
|
-
if (!chord) {
|
|
800
|
-
return [];
|
|
801
|
-
}
|
|
802
|
-
if (chord instanceof ScanCodeChord) {
|
|
803
|
-
return [chord];
|
|
804
|
-
}
|
|
805
|
-
return this.keyCodeChordToScanCodeChord(chord);
|
|
806
|
-
}
|
|
807
|
-
resolveKeybinding(keybinding) {
|
|
808
|
-
const chords = ( keybinding.chords.map(chord => this._resolveChord(chord)));
|
|
809
|
-
return this._toResolvedKeybinding(chords);
|
|
810
|
-
}
|
|
811
|
-
static _redirectCharCode(charCode) {
|
|
812
|
-
switch (charCode) {
|
|
813
|
-
case 12290 : return 46 ;
|
|
814
|
-
case 12300 : return 91 ;
|
|
815
|
-
case 12301 : return 93 ;
|
|
816
|
-
case 12304 : return 91 ;
|
|
817
|
-
case 12305 : return 93 ;
|
|
818
|
-
case 65307 : return 59 ;
|
|
819
|
-
case 65292 : return 44 ;
|
|
820
|
-
}
|
|
821
|
-
return charCode;
|
|
822
|
-
}
|
|
823
|
-
static _charCodeToKb(charCode) {
|
|
824
|
-
charCode = this._redirectCharCode(charCode);
|
|
825
|
-
if (charCode < CHAR_CODE_TO_KEY_CODE.length) {
|
|
826
|
-
return CHAR_CODE_TO_KEY_CODE[charCode];
|
|
827
|
-
}
|
|
828
|
-
return null;
|
|
829
|
-
}
|
|
830
|
-
static getCharCode(char) {
|
|
831
|
-
if (char.length === 0) {
|
|
832
|
-
return 0;
|
|
833
|
-
}
|
|
834
|
-
const charCode = char.charCodeAt(0);
|
|
835
|
-
switch (charCode) {
|
|
836
|
-
case 768 : return 96 ;
|
|
837
|
-
case 769 : return 180 ;
|
|
838
|
-
case 770 : return 94 ;
|
|
839
|
-
case 771 : return 732 ;
|
|
840
|
-
case 772 : return 175 ;
|
|
841
|
-
case 773 : return 8254 ;
|
|
842
|
-
case 774 : return 728 ;
|
|
843
|
-
case 775 : return 729 ;
|
|
844
|
-
case 776 : return 168 ;
|
|
845
|
-
case 778 : return 730 ;
|
|
846
|
-
case 779 : return 733 ;
|
|
847
|
-
}
|
|
848
|
-
return charCode;
|
|
849
|
-
}
|
|
850
|
-
}
|
|
851
|
-
(function () {
|
|
852
|
-
function define(charCode, keyCode, shiftKey) {
|
|
853
|
-
for (let i = CHAR_CODE_TO_KEY_CODE.length; i < charCode; i++) {
|
|
854
|
-
CHAR_CODE_TO_KEY_CODE[i] = null;
|
|
855
|
-
}
|
|
856
|
-
CHAR_CODE_TO_KEY_CODE[charCode] = { keyCode: keyCode, shiftKey: shiftKey };
|
|
857
|
-
}
|
|
858
|
-
for (let chCode = 65 ; chCode <= 90 ; chCode++) {
|
|
859
|
-
define(chCode, 31 + ((chCode - 65) ), true);
|
|
860
|
-
}
|
|
861
|
-
for (let chCode = 97 ; chCode <= 122 ; chCode++) {
|
|
862
|
-
define(chCode, 31 + ((chCode - 97) ), false);
|
|
863
|
-
}
|
|
864
|
-
define(59 , 85 , false);
|
|
865
|
-
define(58 , 85 , true);
|
|
866
|
-
define(61 , 86 , false);
|
|
867
|
-
define(43 , 86 , true);
|
|
868
|
-
define(44 , 87 , false);
|
|
869
|
-
define(60 , 87 , true);
|
|
870
|
-
define(45 , 88 , false);
|
|
871
|
-
define(95 , 88 , true);
|
|
872
|
-
define(46 , 89 , false);
|
|
873
|
-
define(62 , 89 , true);
|
|
874
|
-
define(47 , 90 , false);
|
|
875
|
-
define(63 , 90 , true);
|
|
876
|
-
define(96 , 91 , false);
|
|
877
|
-
define(126 , 91 , true);
|
|
878
|
-
define(91 , 92 , false);
|
|
879
|
-
define(123 , 92 , true);
|
|
880
|
-
define(92 , 93 , false);
|
|
881
|
-
define(124 , 93 , true);
|
|
882
|
-
define(93 , 94 , false);
|
|
883
|
-
define(125 , 94 , true);
|
|
884
|
-
define(39 , 95 , false);
|
|
885
|
-
define(34 , 95 , true);
|
|
886
|
-
})();
|
|
887
|
-
|
|
888
|
-
export { MacLinuxKeyboardMapper, NativeResolvedKeybinding };
|