@codingame/monaco-vscode-keybindings-service-override 5.3.0 → 6.0.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/package.json +3 -3
- package/vscode/src/vs/platform/keyboardLayout/common/keyboardConfig.js +13 -8
- package/vscode/src/vs/workbench/browser/contextkeys.js +41 -81
- package/vscode/src/vs/workbench/contrib/commands/common/commands.contribution.js +5 -4
- package/vscode/src/vs/workbench/contrib/preferences/browser/keybindingsEditorContribution.js +4 -4
- package/vscode/src/vs/workbench/contrib/preferences/common/smartSnippetInserter.js +11 -11
- package/vscode/src/vs/workbench/services/commands/common/commandService.js +1 -0
- package/vscode/src/vs/workbench/services/keybinding/browser/keybindingService.js +51 -49
- package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayoutService.js +5 -4
- package/vscode/src/vs/workbench/services/keybinding/common/macLinuxKeyboardMapper.js +175 -178
- package/vscode/src/vs/workbench/services/keybinding/common/windowsKeyboardMapper.js +70 -68
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CharCode } from 'vscode/vscode/vs/base/common/charCode';
|
|
2
|
+
import { IMMUTABLE_CODE_TO_KEY_CODE, KeyCode, ScanCode, ScanCodeUtils, KeyCodeUtils, IMMUTABLE_KEY_CODE_TO_CODE } from 'vscode/vscode/vs/base/common/keyCodes';
|
|
2
3
|
import { ScanCodeChord, KeyCodeChord } from 'vscode/vscode/vs/base/common/keybindings';
|
|
4
|
+
import { OperatingSystem } from 'vscode/vscode/vs/base/common/platform';
|
|
3
5
|
import { BaseResolvedKeybinding } from 'vscode/vscode/vs/platform/keybinding/common/baseResolvedKeybinding';
|
|
4
6
|
|
|
5
7
|
const CHAR_CODE_TO_KEY_CODE = [];
|
|
@@ -24,7 +26,7 @@ class NativeResolvedKeybinding extends BaseResolvedKeybinding {
|
|
|
24
26
|
if (!binding) {
|
|
25
27
|
return true;
|
|
26
28
|
}
|
|
27
|
-
if (IMMUTABLE_CODE_TO_KEY_CODE[binding.scanCode] !==
|
|
29
|
+
if (IMMUTABLE_CODE_TO_KEY_CODE[binding.scanCode] !== KeyCode.DependsOnKbLayout) {
|
|
28
30
|
return true;
|
|
29
31
|
}
|
|
30
32
|
const a = this._mapper.getAriaLabelForScanCodeChord(binding);
|
|
@@ -41,16 +43,16 @@ class NativeResolvedKeybinding extends BaseResolvedKeybinding {
|
|
|
41
43
|
return this._mapper.getDispatchStrForScanCodeChord(chord);
|
|
42
44
|
}
|
|
43
45
|
_getSingleModifierChordDispatch(chord) {
|
|
44
|
-
if ((
|
|
46
|
+
if ((chord.scanCode === ScanCode.ControlLeft || chord.scanCode === ScanCode.ControlRight) && !chord.shiftKey && !chord.altKey && !chord.metaKey) {
|
|
45
47
|
return 'ctrl';
|
|
46
48
|
}
|
|
47
|
-
if ((
|
|
49
|
+
if ((chord.scanCode === ScanCode.AltLeft || chord.scanCode === ScanCode.AltRight) && !chord.ctrlKey && !chord.shiftKey && !chord.metaKey) {
|
|
48
50
|
return 'alt';
|
|
49
51
|
}
|
|
50
|
-
if ((
|
|
52
|
+
if ((chord.scanCode === ScanCode.ShiftLeft || chord.scanCode === ScanCode.ShiftRight) && !chord.ctrlKey && !chord.altKey && !chord.metaKey) {
|
|
51
53
|
return 'shift';
|
|
52
54
|
}
|
|
53
|
-
if ((
|
|
55
|
+
if ((chord.scanCode === ScanCode.MetaLeft || chord.scanCode === ScanCode.MetaRight) && !chord.ctrlKey && !chord.shiftKey && !chord.altKey) {
|
|
54
56
|
return 'meta';
|
|
55
57
|
}
|
|
56
58
|
return null;
|
|
@@ -92,7 +94,7 @@ class ScanCodeCombo {
|
|
|
92
94
|
if (charCode === 0) {
|
|
93
95
|
return ' --- ';
|
|
94
96
|
}
|
|
95
|
-
if (charCode >=
|
|
97
|
+
if (charCode >= CharCode.U_Combining_Grave_Accent && charCode <= CharCode.U_Combining_Latin_Small_Letter_X) {
|
|
96
98
|
return 'U+' + ( charCode.toString(16));
|
|
97
99
|
}
|
|
98
100
|
return ' ' + String.fromCharCode(charCode) + ' ';
|
|
@@ -117,8 +119,8 @@ class ScanCodeKeyCodeMapper {
|
|
|
117
119
|
this._keyCodeToScanCode = [];
|
|
118
120
|
}
|
|
119
121
|
registrationComplete() {
|
|
120
|
-
this._moveToEnd(
|
|
121
|
-
this._moveToEnd(
|
|
122
|
+
this._moveToEnd(ScanCode.IntlHash);
|
|
123
|
+
this._moveToEnd(ScanCode.IntlBackslash);
|
|
122
124
|
}
|
|
123
125
|
_moveToEnd(scanCode) {
|
|
124
126
|
for (let mod = 0; mod < 8; mod++) {
|
|
@@ -145,13 +147,13 @@ class ScanCodeKeyCodeMapper {
|
|
|
145
147
|
}
|
|
146
148
|
}
|
|
147
149
|
registerIfUnknown(scanCodeCombo, keyCodeCombo) {
|
|
148
|
-
if (keyCodeCombo.keyCode ===
|
|
150
|
+
if (keyCodeCombo.keyCode === KeyCode.Unknown) {
|
|
149
151
|
return;
|
|
150
152
|
}
|
|
151
153
|
const scanCodeComboEncoded = this._encodeScanCodeCombo(scanCodeCombo);
|
|
152
154
|
const keyCodeComboEncoded = this._encodeKeyCodeCombo(keyCodeCombo);
|
|
153
|
-
const keyCodeIsDigit = (
|
|
154
|
-
const keyCodeIsLetter = (
|
|
155
|
+
const keyCodeIsDigit = (keyCodeCombo.keyCode >= KeyCode.Digit0 && keyCodeCombo.keyCode <= KeyCode.Digit9);
|
|
156
|
+
const keyCodeIsLetter = (keyCodeCombo.keyCode >= KeyCode.KeyA && keyCodeCombo.keyCode <= KeyCode.KeyZ);
|
|
155
157
|
const existingKeyCodeCombos = this._scanCodeToKeyCode[scanCodeComboEncoded];
|
|
156
158
|
if (keyCodeIsDigit || keyCodeIsLetter) {
|
|
157
159
|
if (existingKeyCodeCombos) {
|
|
@@ -207,18 +209,18 @@ class ScanCodeKeyCodeMapper {
|
|
|
207
209
|
return result;
|
|
208
210
|
}
|
|
209
211
|
guessStableKeyCode(scanCode) {
|
|
210
|
-
if (scanCode >=
|
|
212
|
+
if (scanCode >= ScanCode.Digit1 && scanCode <= ScanCode.Digit0) {
|
|
211
213
|
switch (scanCode) {
|
|
212
|
-
case
|
|
213
|
-
case
|
|
214
|
-
case
|
|
215
|
-
case
|
|
216
|
-
case
|
|
217
|
-
case
|
|
218
|
-
case
|
|
219
|
-
case
|
|
220
|
-
case
|
|
221
|
-
case
|
|
214
|
+
case ScanCode.Digit1: return KeyCode.Digit1;
|
|
215
|
+
case ScanCode.Digit2: return KeyCode.Digit2;
|
|
216
|
+
case ScanCode.Digit3: return KeyCode.Digit3;
|
|
217
|
+
case ScanCode.Digit4: return KeyCode.Digit4;
|
|
218
|
+
case ScanCode.Digit5: return KeyCode.Digit5;
|
|
219
|
+
case ScanCode.Digit6: return KeyCode.Digit6;
|
|
220
|
+
case ScanCode.Digit7: return KeyCode.Digit7;
|
|
221
|
+
case ScanCode.Digit8: return KeyCode.Digit8;
|
|
222
|
+
case ScanCode.Digit9: return KeyCode.Digit9;
|
|
223
|
+
case ScanCode.Digit0: return KeyCode.Digit0;
|
|
222
224
|
}
|
|
223
225
|
}
|
|
224
226
|
const keyCodeCombos1 = this.lookupScanCodeCombo(( new ScanCodeCombo(false, false, false, scanCode)));
|
|
@@ -232,7 +234,7 @@ class ScanCodeKeyCodeMapper {
|
|
|
232
234
|
return keyCode1;
|
|
233
235
|
}
|
|
234
236
|
}
|
|
235
|
-
return
|
|
237
|
+
return KeyCode.DependsOnKbLayout;
|
|
236
238
|
}
|
|
237
239
|
_encodeScanCodeCombo(scanCodeCombo) {
|
|
238
240
|
return this._encode(scanCodeCombo.ctrlKey, scanCodeCombo.shiftKey, scanCodeCombo.altKey, scanCodeCombo.scanCode);
|
|
@@ -280,18 +282,18 @@ class MacLinuxKeyboardMapper {
|
|
|
280
282
|
}
|
|
281
283
|
}
|
|
282
284
|
};
|
|
283
|
-
for (let scanCode =
|
|
285
|
+
for (let scanCode = ScanCode.None; scanCode < ScanCode.MAX_VALUE; scanCode++) {
|
|
284
286
|
this._scanCodeToLabel[scanCode] = null;
|
|
285
287
|
}
|
|
286
|
-
for (let scanCode =
|
|
288
|
+
for (let scanCode = ScanCode.None; scanCode < ScanCode.MAX_VALUE; scanCode++) {
|
|
287
289
|
this._scanCodeToDispatch[scanCode] = null;
|
|
288
290
|
}
|
|
289
|
-
for (let scanCode =
|
|
291
|
+
for (let scanCode = ScanCode.None; scanCode < ScanCode.MAX_VALUE; scanCode++) {
|
|
290
292
|
const keyCode = IMMUTABLE_CODE_TO_KEY_CODE[scanCode];
|
|
291
|
-
if (keyCode !==
|
|
293
|
+
if (keyCode !== KeyCode.DependsOnKbLayout) {
|
|
292
294
|
_registerAllCombos(0, 0, 0, scanCode, keyCode);
|
|
293
295
|
this._scanCodeToLabel[scanCode] = ( KeyCodeUtils.toString(keyCode));
|
|
294
|
-
if (keyCode ===
|
|
296
|
+
if (keyCode === KeyCode.Unknown || keyCode === KeyCode.Ctrl || keyCode === KeyCode.Meta || keyCode === KeyCode.Alt || keyCode === KeyCode.Shift) {
|
|
295
297
|
this._scanCodeToDispatch[scanCode] = null;
|
|
296
298
|
}
|
|
297
299
|
else {
|
|
@@ -305,16 +307,16 @@ class MacLinuxKeyboardMapper {
|
|
|
305
307
|
for (const strScanCode in rawMappings) {
|
|
306
308
|
if (rawMappings.hasOwnProperty(strScanCode)) {
|
|
307
309
|
const scanCode = ScanCodeUtils.toEnum(strScanCode);
|
|
308
|
-
if (scanCode ===
|
|
310
|
+
if (scanCode === ScanCode.None) {
|
|
309
311
|
continue;
|
|
310
312
|
}
|
|
311
|
-
if (IMMUTABLE_CODE_TO_KEY_CODE[scanCode] !==
|
|
313
|
+
if (IMMUTABLE_CODE_TO_KEY_CODE[scanCode] !== KeyCode.DependsOnKbLayout) {
|
|
312
314
|
continue;
|
|
313
315
|
}
|
|
314
316
|
const rawMapping = rawMappings[strScanCode];
|
|
315
317
|
const value = MacLinuxKeyboardMapper.getCharCode(rawMapping.value);
|
|
316
|
-
if (value >=
|
|
317
|
-
const upperCaseValue =
|
|
318
|
+
if (value >= CharCode.a && value <= CharCode.z) {
|
|
319
|
+
const upperCaseValue = CharCode.A + (value - CharCode.a);
|
|
318
320
|
producesLatinLetter[upperCaseValue] = true;
|
|
319
321
|
}
|
|
320
322
|
}
|
|
@@ -329,42 +331,42 @@ class MacLinuxKeyboardMapper {
|
|
|
329
331
|
};
|
|
330
332
|
}
|
|
331
333
|
};
|
|
332
|
-
_registerLetterIfMissing(
|
|
333
|
-
_registerLetterIfMissing(
|
|
334
|
-
_registerLetterIfMissing(
|
|
335
|
-
_registerLetterIfMissing(
|
|
336
|
-
_registerLetterIfMissing(
|
|
337
|
-
_registerLetterIfMissing(
|
|
338
|
-
_registerLetterIfMissing(
|
|
339
|
-
_registerLetterIfMissing(
|
|
340
|
-
_registerLetterIfMissing(
|
|
341
|
-
_registerLetterIfMissing(
|
|
342
|
-
_registerLetterIfMissing(
|
|
343
|
-
_registerLetterIfMissing(
|
|
344
|
-
_registerLetterIfMissing(
|
|
345
|
-
_registerLetterIfMissing(
|
|
346
|
-
_registerLetterIfMissing(
|
|
347
|
-
_registerLetterIfMissing(
|
|
348
|
-
_registerLetterIfMissing(
|
|
349
|
-
_registerLetterIfMissing(
|
|
350
|
-
_registerLetterIfMissing(
|
|
351
|
-
_registerLetterIfMissing(
|
|
352
|
-
_registerLetterIfMissing(
|
|
353
|
-
_registerLetterIfMissing(
|
|
354
|
-
_registerLetterIfMissing(
|
|
355
|
-
_registerLetterIfMissing(
|
|
356
|
-
_registerLetterIfMissing(
|
|
357
|
-
_registerLetterIfMissing(
|
|
334
|
+
_registerLetterIfMissing(CharCode.A, ScanCode.KeyA, 'a', 'A');
|
|
335
|
+
_registerLetterIfMissing(CharCode.B, ScanCode.KeyB, 'b', 'B');
|
|
336
|
+
_registerLetterIfMissing(CharCode.C, ScanCode.KeyC, 'c', 'C');
|
|
337
|
+
_registerLetterIfMissing(CharCode.D, ScanCode.KeyD, 'd', 'D');
|
|
338
|
+
_registerLetterIfMissing(CharCode.E, ScanCode.KeyE, 'e', 'E');
|
|
339
|
+
_registerLetterIfMissing(CharCode.F, ScanCode.KeyF, 'f', 'F');
|
|
340
|
+
_registerLetterIfMissing(CharCode.G, ScanCode.KeyG, 'g', 'G');
|
|
341
|
+
_registerLetterIfMissing(CharCode.H, ScanCode.KeyH, 'h', 'H');
|
|
342
|
+
_registerLetterIfMissing(CharCode.I, ScanCode.KeyI, 'i', 'I');
|
|
343
|
+
_registerLetterIfMissing(CharCode.J, ScanCode.KeyJ, 'j', 'J');
|
|
344
|
+
_registerLetterIfMissing(CharCode.K, ScanCode.KeyK, 'k', 'K');
|
|
345
|
+
_registerLetterIfMissing(CharCode.L, ScanCode.KeyL, 'l', 'L');
|
|
346
|
+
_registerLetterIfMissing(CharCode.M, ScanCode.KeyM, 'm', 'M');
|
|
347
|
+
_registerLetterIfMissing(CharCode.N, ScanCode.KeyN, 'n', 'N');
|
|
348
|
+
_registerLetterIfMissing(CharCode.O, ScanCode.KeyO, 'o', 'O');
|
|
349
|
+
_registerLetterIfMissing(CharCode.P, ScanCode.KeyP, 'p', 'P');
|
|
350
|
+
_registerLetterIfMissing(CharCode.Q, ScanCode.KeyQ, 'q', 'Q');
|
|
351
|
+
_registerLetterIfMissing(CharCode.R, ScanCode.KeyR, 'r', 'R');
|
|
352
|
+
_registerLetterIfMissing(CharCode.S, ScanCode.KeyS, 's', 'S');
|
|
353
|
+
_registerLetterIfMissing(CharCode.T, ScanCode.KeyT, 't', 'T');
|
|
354
|
+
_registerLetterIfMissing(CharCode.U, ScanCode.KeyU, 'u', 'U');
|
|
355
|
+
_registerLetterIfMissing(CharCode.V, ScanCode.KeyV, 'v', 'V');
|
|
356
|
+
_registerLetterIfMissing(CharCode.W, ScanCode.KeyW, 'w', 'W');
|
|
357
|
+
_registerLetterIfMissing(CharCode.X, ScanCode.KeyX, 'x', 'X');
|
|
358
|
+
_registerLetterIfMissing(CharCode.Y, ScanCode.KeyY, 'y', 'Y');
|
|
359
|
+
_registerLetterIfMissing(CharCode.Z, ScanCode.KeyZ, 'z', 'Z');
|
|
358
360
|
}
|
|
359
361
|
const mappings = [];
|
|
360
362
|
let mappingsLen = 0;
|
|
361
363
|
for (const strScanCode in rawMappings) {
|
|
362
364
|
if (rawMappings.hasOwnProperty(strScanCode)) {
|
|
363
365
|
const scanCode = ScanCodeUtils.toEnum(strScanCode);
|
|
364
|
-
if (scanCode ===
|
|
366
|
+
if (scanCode === ScanCode.None) {
|
|
365
367
|
continue;
|
|
366
368
|
}
|
|
367
|
-
if (IMMUTABLE_CODE_TO_KEY_CODE[scanCode] !==
|
|
369
|
+
if (IMMUTABLE_CODE_TO_KEY_CODE[scanCode] !== KeyCode.DependsOnKbLayout) {
|
|
368
370
|
continue;
|
|
369
371
|
}
|
|
370
372
|
this._codeInfo[scanCode] = rawMappings[strScanCode];
|
|
@@ -382,11 +384,11 @@ class MacLinuxKeyboardMapper {
|
|
|
382
384
|
};
|
|
383
385
|
mappings[mappingsLen++] = mapping;
|
|
384
386
|
this._scanCodeToDispatch[scanCode] = `[${( ScanCodeUtils.toString(scanCode))}]`;
|
|
385
|
-
if (value >=
|
|
386
|
-
const upperCaseValue =
|
|
387
|
+
if (value >= CharCode.a && value <= CharCode.z) {
|
|
388
|
+
const upperCaseValue = CharCode.A + (value - CharCode.a);
|
|
387
389
|
this._scanCodeToLabel[scanCode] = String.fromCharCode(upperCaseValue);
|
|
388
390
|
}
|
|
389
|
-
else if (value >=
|
|
391
|
+
else if (value >= CharCode.A && value <= CharCode.Z) {
|
|
390
392
|
this._scanCodeToLabel[scanCode] = String.fromCharCode(value);
|
|
391
393
|
}
|
|
392
394
|
else if (value) {
|
|
@@ -493,29 +495,29 @@ class MacLinuxKeyboardMapper {
|
|
|
493
495
|
_registerIfUnknown(1, 1, 1, scanCode, 1, 1, 1, keyCode);
|
|
494
496
|
}
|
|
495
497
|
}
|
|
496
|
-
_registerAllCombos(0, 0, 0,
|
|
497
|
-
_registerAllCombos(0, 0, 0,
|
|
498
|
-
_registerAllCombos(0, 0, 0,
|
|
499
|
-
_registerAllCombos(0, 0, 0,
|
|
500
|
-
_registerAllCombos(0, 0, 0,
|
|
501
|
-
_registerAllCombos(0, 0, 0,
|
|
502
|
-
_registerAllCombos(0, 0, 0,
|
|
503
|
-
_registerAllCombos(0, 0, 0,
|
|
504
|
-
_registerAllCombos(0, 0, 0,
|
|
505
|
-
_registerAllCombos(0, 0, 0,
|
|
498
|
+
_registerAllCombos(0, 0, 0, ScanCode.Digit1, KeyCode.Digit1);
|
|
499
|
+
_registerAllCombos(0, 0, 0, ScanCode.Digit2, KeyCode.Digit2);
|
|
500
|
+
_registerAllCombos(0, 0, 0, ScanCode.Digit3, KeyCode.Digit3);
|
|
501
|
+
_registerAllCombos(0, 0, 0, ScanCode.Digit4, KeyCode.Digit4);
|
|
502
|
+
_registerAllCombos(0, 0, 0, ScanCode.Digit5, KeyCode.Digit5);
|
|
503
|
+
_registerAllCombos(0, 0, 0, ScanCode.Digit6, KeyCode.Digit6);
|
|
504
|
+
_registerAllCombos(0, 0, 0, ScanCode.Digit7, KeyCode.Digit7);
|
|
505
|
+
_registerAllCombos(0, 0, 0, ScanCode.Digit8, KeyCode.Digit8);
|
|
506
|
+
_registerAllCombos(0, 0, 0, ScanCode.Digit9, KeyCode.Digit9);
|
|
507
|
+
_registerAllCombos(0, 0, 0, ScanCode.Digit0, KeyCode.Digit0);
|
|
506
508
|
this._scanCodeKeyCodeMapper.registrationComplete();
|
|
507
509
|
}
|
|
508
510
|
dumpDebugInfo() {
|
|
509
511
|
const result = [];
|
|
510
512
|
const immutableSamples = [
|
|
511
|
-
|
|
512
|
-
|
|
513
|
+
ScanCode.ArrowUp,
|
|
514
|
+
ScanCode.Numpad0
|
|
513
515
|
];
|
|
514
516
|
let cnt = 0;
|
|
515
517
|
result.push(`isUSStandard: ${this._isUSStandard}`);
|
|
516
518
|
result.push(`----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------`);
|
|
517
|
-
for (let scanCode =
|
|
518
|
-
if (IMMUTABLE_CODE_TO_KEY_CODE[scanCode] !==
|
|
519
|
+
for (let scanCode = ScanCode.None; scanCode < ScanCode.MAX_VALUE; scanCode++) {
|
|
520
|
+
if (IMMUTABLE_CODE_TO_KEY_CODE[scanCode] !== KeyCode.DependsOnKbLayout) {
|
|
519
521
|
if (immutableSamples.indexOf(scanCode) === -1) {
|
|
520
522
|
continue;
|
|
521
523
|
}
|
|
@@ -538,7 +540,7 @@ class MacLinuxKeyboardMapper {
|
|
|
538
540
|
altKey: scanCodeCombo.altKey,
|
|
539
541
|
metaKey: false,
|
|
540
542
|
altGraphKey: false,
|
|
541
|
-
keyCode:
|
|
543
|
+
keyCode: KeyCode.DependsOnKbLayout,
|
|
542
544
|
code: ( ScanCodeUtils.toString(scanCode))
|
|
543
545
|
});
|
|
544
546
|
const outScanCodeCombo = ( scanCodeCombo.toString());
|
|
@@ -596,14 +598,8 @@ class MacLinuxKeyboardMapper {
|
|
|
596
598
|
return str;
|
|
597
599
|
}
|
|
598
600
|
keyCodeChordToScanCodeChord(chord) {
|
|
599
|
-
if (chord.keyCode ===
|
|
600
|
-
return [( new ScanCodeChord(
|
|
601
|
-
chord.ctrlKey,
|
|
602
|
-
chord.shiftKey,
|
|
603
|
-
chord.altKey,
|
|
604
|
-
chord.metaKey,
|
|
605
|
-
46
|
|
606
|
-
))];
|
|
601
|
+
if (chord.keyCode === KeyCode.Enter) {
|
|
602
|
+
return [( new ScanCodeChord(chord.ctrlKey, chord.shiftKey, chord.altKey, chord.metaKey, ScanCode.Enter))];
|
|
607
603
|
}
|
|
608
604
|
const scanCodeCombos = this._scanCodeKeyCodeMapper.lookupKeyCodeCombo(( new KeyCodeCombo(chord.ctrlKey, chord.shiftKey, chord.altKey, chord.keyCode)));
|
|
609
605
|
const result = [];
|
|
@@ -626,15 +622,15 @@ class MacLinuxKeyboardMapper {
|
|
|
626
622
|
if (chord.isDuplicateModifierCase()) {
|
|
627
623
|
return '';
|
|
628
624
|
}
|
|
629
|
-
if (this._OS ===
|
|
625
|
+
if (this._OS === OperatingSystem.Macintosh) {
|
|
630
626
|
switch (chord.scanCode) {
|
|
631
|
-
case
|
|
627
|
+
case ScanCode.ArrowLeft:
|
|
632
628
|
return '←';
|
|
633
|
-
case
|
|
629
|
+
case ScanCode.ArrowUp:
|
|
634
630
|
return '↑';
|
|
635
|
-
case
|
|
631
|
+
case ScanCode.ArrowRight:
|
|
636
632
|
return '→';
|
|
637
|
-
case
|
|
633
|
+
case ScanCode.ArrowDown:
|
|
638
634
|
return '↓';
|
|
639
635
|
}
|
|
640
636
|
}
|
|
@@ -678,11 +674,11 @@ class MacLinuxKeyboardMapper {
|
|
|
678
674
|
return '';
|
|
679
675
|
}
|
|
680
676
|
const immutableKeyCode = IMMUTABLE_CODE_TO_KEY_CODE[chord.scanCode];
|
|
681
|
-
if (immutableKeyCode !==
|
|
677
|
+
if (immutableKeyCode !== KeyCode.DependsOnKbLayout) {
|
|
682
678
|
return KeyCodeUtils.toUserSettingsUS(immutableKeyCode).toLowerCase();
|
|
683
679
|
}
|
|
684
680
|
const constantKeyCode = this._scanCodeKeyCodeMapper.guessStableKeyCode(chord.scanCode);
|
|
685
|
-
if (constantKeyCode !==
|
|
681
|
+
if (constantKeyCode !== KeyCode.DependsOnKbLayout) {
|
|
686
682
|
const reverseChords = this.keyCodeChordToScanCodeChord(( new KeyCodeChord(
|
|
687
683
|
chord.ctrlKey,
|
|
688
684
|
chord.shiftKey,
|
|
@@ -704,25 +700,26 @@ class MacLinuxKeyboardMapper {
|
|
|
704
700
|
return null;
|
|
705
701
|
}
|
|
706
702
|
const immutableKeyCode = IMMUTABLE_CODE_TO_KEY_CODE[chord.scanCode];
|
|
707
|
-
if (immutableKeyCode !==
|
|
703
|
+
if (immutableKeyCode !== KeyCode.DependsOnKbLayout) {
|
|
708
704
|
return KeyCodeUtils.toElectronAccelerator(immutableKeyCode);
|
|
709
705
|
}
|
|
710
706
|
const constantKeyCode = this._scanCodeKeyCodeMapper.guessStableKeyCode(chord.scanCode);
|
|
711
|
-
if (this._OS ===
|
|
712
|
-
const isOEMKey = (
|
|
713
|
-
|| constantKeyCode ===
|
|
714
|
-
|| constantKeyCode ===
|
|
715
|
-
|| constantKeyCode ===
|
|
716
|
-
|| constantKeyCode ===
|
|
717
|
-
|| constantKeyCode ===
|
|
718
|
-
|| constantKeyCode ===
|
|
719
|
-
|| constantKeyCode ===
|
|
720
|
-
|| constantKeyCode ===
|
|
707
|
+
if (this._OS === OperatingSystem.Linux && !this._isUSStandard) {
|
|
708
|
+
const isOEMKey = (constantKeyCode === KeyCode.Semicolon
|
|
709
|
+
|| constantKeyCode === KeyCode.Equal
|
|
710
|
+
|| constantKeyCode === KeyCode.Comma
|
|
711
|
+
|| constantKeyCode === KeyCode.Minus
|
|
712
|
+
|| constantKeyCode === KeyCode.Period
|
|
713
|
+
|| constantKeyCode === KeyCode.Slash
|
|
714
|
+
|| constantKeyCode === KeyCode.Backquote
|
|
715
|
+
|| constantKeyCode === KeyCode.BracketLeft
|
|
716
|
+
|| constantKeyCode === KeyCode.Backslash
|
|
717
|
+
|| constantKeyCode === KeyCode.BracketRight);
|
|
721
718
|
if (isOEMKey) {
|
|
722
719
|
return null;
|
|
723
720
|
}
|
|
724
721
|
}
|
|
725
|
-
if (constantKeyCode !==
|
|
722
|
+
if (constantKeyCode !== KeyCode.DependsOnKbLayout) {
|
|
726
723
|
return KeyCodeUtils.toElectronAccelerator(constantKeyCode);
|
|
727
724
|
}
|
|
728
725
|
return null;
|
|
@@ -750,41 +747,41 @@ class MacLinuxKeyboardMapper {
|
|
|
750
747
|
}
|
|
751
748
|
resolveKeyboardEvent(keyboardEvent) {
|
|
752
749
|
let code = ScanCodeUtils.toEnum(keyboardEvent.code);
|
|
753
|
-
if (code ===
|
|
754
|
-
code =
|
|
750
|
+
if (code === ScanCode.NumpadEnter) {
|
|
751
|
+
code = ScanCode.Enter;
|
|
755
752
|
}
|
|
756
753
|
const keyCode = keyboardEvent.keyCode;
|
|
757
|
-
if ((
|
|
758
|
-
|| (
|
|
759
|
-
|| (
|
|
760
|
-
|| (
|
|
761
|
-
|| (
|
|
762
|
-
|| (
|
|
763
|
-
|| (
|
|
764
|
-
|| (
|
|
765
|
-
|| (
|
|
766
|
-
|| (
|
|
767
|
-
|| (
|
|
754
|
+
if ((keyCode === KeyCode.LeftArrow)
|
|
755
|
+
|| (keyCode === KeyCode.UpArrow)
|
|
756
|
+
|| (keyCode === KeyCode.RightArrow)
|
|
757
|
+
|| (keyCode === KeyCode.DownArrow)
|
|
758
|
+
|| (keyCode === KeyCode.Delete)
|
|
759
|
+
|| (keyCode === KeyCode.Insert)
|
|
760
|
+
|| (keyCode === KeyCode.Home)
|
|
761
|
+
|| (keyCode === KeyCode.End)
|
|
762
|
+
|| (keyCode === KeyCode.PageDown)
|
|
763
|
+
|| (keyCode === KeyCode.PageUp)
|
|
764
|
+
|| (keyCode === KeyCode.Backspace)) {
|
|
768
765
|
const immutableScanCode = IMMUTABLE_KEY_CODE_TO_CODE[keyCode];
|
|
769
|
-
if (immutableScanCode !==
|
|
766
|
+
if (immutableScanCode !== ScanCode.DependsOnKbLayout) {
|
|
770
767
|
code = immutableScanCode;
|
|
771
768
|
}
|
|
772
769
|
}
|
|
773
770
|
else {
|
|
774
|
-
if ((
|
|
775
|
-
|| (
|
|
776
|
-
|| (
|
|
777
|
-
|| (
|
|
778
|
-
|| (
|
|
779
|
-
|| (
|
|
780
|
-
|| (
|
|
781
|
-
|| (
|
|
782
|
-
|| (
|
|
783
|
-
|| (
|
|
784
|
-
|| (
|
|
771
|
+
if ((code === ScanCode.Numpad1)
|
|
772
|
+
|| (code === ScanCode.Numpad2)
|
|
773
|
+
|| (code === ScanCode.Numpad3)
|
|
774
|
+
|| (code === ScanCode.Numpad4)
|
|
775
|
+
|| (code === ScanCode.Numpad5)
|
|
776
|
+
|| (code === ScanCode.Numpad6)
|
|
777
|
+
|| (code === ScanCode.Numpad7)
|
|
778
|
+
|| (code === ScanCode.Numpad8)
|
|
779
|
+
|| (code === ScanCode.Numpad9)
|
|
780
|
+
|| (code === ScanCode.Numpad0)
|
|
781
|
+
|| (code === ScanCode.NumpadDecimal)) {
|
|
785
782
|
if (keyCode >= 0) {
|
|
786
783
|
const immutableScanCode = IMMUTABLE_KEY_CODE_TO_CODE[keyCode];
|
|
787
|
-
if (immutableScanCode !==
|
|
784
|
+
if (immutableScanCode !== ScanCode.DependsOnKbLayout) {
|
|
788
785
|
code = immutableScanCode;
|
|
789
786
|
}
|
|
790
787
|
}
|
|
@@ -810,13 +807,13 @@ class MacLinuxKeyboardMapper {
|
|
|
810
807
|
}
|
|
811
808
|
static _redirectCharCode(charCode) {
|
|
812
809
|
switch (charCode) {
|
|
813
|
-
case
|
|
814
|
-
case
|
|
815
|
-
case
|
|
816
|
-
case
|
|
817
|
-
case
|
|
818
|
-
case
|
|
819
|
-
case
|
|
810
|
+
case CharCode.U_IDEOGRAPHIC_FULL_STOP: return CharCode.Period;
|
|
811
|
+
case CharCode.U_LEFT_CORNER_BRACKET: return CharCode.OpenSquareBracket;
|
|
812
|
+
case CharCode.U_RIGHT_CORNER_BRACKET: return CharCode.CloseSquareBracket;
|
|
813
|
+
case CharCode.U_LEFT_BLACK_LENTICULAR_BRACKET: return CharCode.OpenSquareBracket;
|
|
814
|
+
case CharCode.U_RIGHT_BLACK_LENTICULAR_BRACKET: return CharCode.CloseSquareBracket;
|
|
815
|
+
case CharCode.U_FULLWIDTH_SEMICOLON: return CharCode.Semicolon;
|
|
816
|
+
case CharCode.U_FULLWIDTH_COMMA: return CharCode.Comma;
|
|
820
817
|
}
|
|
821
818
|
return charCode;
|
|
822
819
|
}
|
|
@@ -833,17 +830,17 @@ class MacLinuxKeyboardMapper {
|
|
|
833
830
|
}
|
|
834
831
|
const charCode = char.charCodeAt(0);
|
|
835
832
|
switch (charCode) {
|
|
836
|
-
case
|
|
837
|
-
case
|
|
838
|
-
case
|
|
839
|
-
case
|
|
840
|
-
case
|
|
841
|
-
case
|
|
842
|
-
case
|
|
843
|
-
case
|
|
844
|
-
case
|
|
845
|
-
case
|
|
846
|
-
case
|
|
833
|
+
case CharCode.U_Combining_Grave_Accent: return CharCode.U_GRAVE_ACCENT;
|
|
834
|
+
case CharCode.U_Combining_Acute_Accent: return CharCode.U_ACUTE_ACCENT;
|
|
835
|
+
case CharCode.U_Combining_Circumflex_Accent: return CharCode.U_CIRCUMFLEX;
|
|
836
|
+
case CharCode.U_Combining_Tilde: return CharCode.U_SMALL_TILDE;
|
|
837
|
+
case CharCode.U_Combining_Macron: return CharCode.U_MACRON;
|
|
838
|
+
case CharCode.U_Combining_Overline: return CharCode.U_OVERLINE;
|
|
839
|
+
case CharCode.U_Combining_Breve: return CharCode.U_BREVE;
|
|
840
|
+
case CharCode.U_Combining_Dot_Above: return CharCode.U_DOT_ABOVE;
|
|
841
|
+
case CharCode.U_Combining_Diaeresis: return CharCode.U_DIAERESIS;
|
|
842
|
+
case CharCode.U_Combining_Ring_Above: return CharCode.U_RING_ABOVE;
|
|
843
|
+
case CharCode.U_Combining_Double_Acute_Accent: return CharCode.U_DOUBLE_ACUTE_ACCENT;
|
|
847
844
|
}
|
|
848
845
|
return charCode;
|
|
849
846
|
}
|
|
@@ -855,34 +852,34 @@ class MacLinuxKeyboardMapper {
|
|
|
855
852
|
}
|
|
856
853
|
CHAR_CODE_TO_KEY_CODE[charCode] = { keyCode: keyCode, shiftKey: shiftKey };
|
|
857
854
|
}
|
|
858
|
-
for (let chCode =
|
|
859
|
-
define(chCode,
|
|
860
|
-
}
|
|
861
|
-
for (let chCode =
|
|
862
|
-
define(chCode,
|
|
863
|
-
}
|
|
864
|
-
define(
|
|
865
|
-
define(
|
|
866
|
-
define(
|
|
867
|
-
define(
|
|
868
|
-
define(
|
|
869
|
-
define(
|
|
870
|
-
define(
|
|
871
|
-
define(
|
|
872
|
-
define(
|
|
873
|
-
define(
|
|
874
|
-
define(
|
|
875
|
-
define(
|
|
876
|
-
define(
|
|
877
|
-
define(
|
|
878
|
-
define(
|
|
879
|
-
define(
|
|
880
|
-
define(
|
|
881
|
-
define(
|
|
882
|
-
define(
|
|
883
|
-
define(
|
|
884
|
-
define(
|
|
885
|
-
define(
|
|
855
|
+
for (let chCode = CharCode.A; chCode <= CharCode.Z; chCode++) {
|
|
856
|
+
define(chCode, KeyCode.KeyA + (chCode - CharCode.A), true);
|
|
857
|
+
}
|
|
858
|
+
for (let chCode = CharCode.a; chCode <= CharCode.z; chCode++) {
|
|
859
|
+
define(chCode, KeyCode.KeyA + (chCode - CharCode.a), false);
|
|
860
|
+
}
|
|
861
|
+
define(CharCode.Semicolon, KeyCode.Semicolon, false);
|
|
862
|
+
define(CharCode.Colon, KeyCode.Semicolon, true);
|
|
863
|
+
define(CharCode.Equals, KeyCode.Equal, false);
|
|
864
|
+
define(CharCode.Plus, KeyCode.Equal, true);
|
|
865
|
+
define(CharCode.Comma, KeyCode.Comma, false);
|
|
866
|
+
define(CharCode.LessThan, KeyCode.Comma, true);
|
|
867
|
+
define(CharCode.Dash, KeyCode.Minus, false);
|
|
868
|
+
define(CharCode.Underline, KeyCode.Minus, true);
|
|
869
|
+
define(CharCode.Period, KeyCode.Period, false);
|
|
870
|
+
define(CharCode.GreaterThan, KeyCode.Period, true);
|
|
871
|
+
define(CharCode.Slash, KeyCode.Slash, false);
|
|
872
|
+
define(CharCode.QuestionMark, KeyCode.Slash, true);
|
|
873
|
+
define(CharCode.BackTick, KeyCode.Backquote, false);
|
|
874
|
+
define(CharCode.Tilde, KeyCode.Backquote, true);
|
|
875
|
+
define(CharCode.OpenSquareBracket, KeyCode.BracketLeft, false);
|
|
876
|
+
define(CharCode.OpenCurlyBrace, KeyCode.BracketLeft, true);
|
|
877
|
+
define(CharCode.Backslash, KeyCode.Backslash, false);
|
|
878
|
+
define(CharCode.Pipe, KeyCode.Backslash, true);
|
|
879
|
+
define(CharCode.CloseSquareBracket, KeyCode.BracketRight, false);
|
|
880
|
+
define(CharCode.CloseCurlyBrace, KeyCode.BracketRight, true);
|
|
881
|
+
define(CharCode.SingleQuote, KeyCode.Quote, false);
|
|
882
|
+
define(CharCode.DoubleQuote, KeyCode.Quote, true);
|
|
886
883
|
})();
|
|
887
884
|
|
|
888
885
|
export { MacLinuxKeyboardMapper, NativeResolvedKeybinding };
|