@codingame/monaco-vscode-keybindings-service-override 5.3.0 → 6.0.1

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.
@@ -1,5 +1,7 @@
1
- import { IMMUTABLE_CODE_TO_KEY_CODE, ScanCodeUtils, KeyCodeUtils, IMMUTABLE_KEY_CODE_TO_CODE } from 'vscode/vscode/vs/base/common/keyCodes';
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] !== -1 ) {
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 (((chord.scanCode === 157 || chord.scanCode === 161) ) && !chord.shiftKey && !chord.altKey && !chord.metaKey) {
46
+ if ((chord.scanCode === ScanCode.ControlLeft || chord.scanCode === ScanCode.ControlRight) && !chord.shiftKey && !chord.altKey && !chord.metaKey) {
45
47
  return 'ctrl';
46
48
  }
47
- if (((chord.scanCode === 159 || chord.scanCode === 163) ) && !chord.ctrlKey && !chord.shiftKey && !chord.metaKey) {
49
+ if ((chord.scanCode === ScanCode.AltLeft || chord.scanCode === ScanCode.AltRight) && !chord.ctrlKey && !chord.shiftKey && !chord.metaKey) {
48
50
  return 'alt';
49
51
  }
50
- if (((chord.scanCode === 158 || chord.scanCode === 162) ) && !chord.ctrlKey && !chord.altKey && !chord.metaKey) {
52
+ if ((chord.scanCode === ScanCode.ShiftLeft || chord.scanCode === ScanCode.ShiftRight) && !chord.ctrlKey && !chord.altKey && !chord.metaKey) {
51
53
  return 'shift';
52
54
  }
53
- if (((chord.scanCode === 160 || chord.scanCode === 164) ) && !chord.ctrlKey && !chord.shiftKey && !chord.altKey) {
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 >= 768 && charCode <= 879 ) {
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(56 );
121
- this._moveToEnd(106 );
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 === 0 ) {
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 = ((keyCodeCombo.keyCode >= 21 && keyCodeCombo.keyCode <= 30) );
154
- const keyCodeIsLetter = ((keyCodeCombo.keyCode >= 31 && keyCodeCombo.keyCode <= 56) );
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 >= 36 && scanCode <= 45 ) {
212
+ if (scanCode >= ScanCode.Digit1 && scanCode <= ScanCode.Digit0) {
211
213
  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 ;
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 -1 ;
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 = 0 ; scanCode < 193 ; scanCode++) {
285
+ for (let scanCode = ScanCode.None; scanCode < ScanCode.MAX_VALUE; scanCode++) {
284
286
  this._scanCodeToLabel[scanCode] = null;
285
287
  }
286
- for (let scanCode = 0 ; scanCode < 193 ; scanCode++) {
288
+ for (let scanCode = ScanCode.None; scanCode < ScanCode.MAX_VALUE; scanCode++) {
287
289
  this._scanCodeToDispatch[scanCode] = null;
288
290
  }
289
- for (let scanCode = 0 ; scanCode < 193 ; 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 !== -1 ) {
293
+ if (keyCode !== KeyCode.DependsOnKbLayout) {
292
294
  _registerAllCombos(0, 0, 0, scanCode, keyCode);
293
295
  this._scanCodeToLabel[scanCode] = ( KeyCodeUtils.toString(keyCode));
294
- if (keyCode === 0 || keyCode === 5 || keyCode === 57 || keyCode === 6 || keyCode === 4 ) {
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 === 0 ) {
310
+ if (scanCode === ScanCode.None) {
309
311
  continue;
310
312
  }
311
- if (IMMUTABLE_CODE_TO_KEY_CODE[scanCode] !== -1 ) {
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 >= 97 && value <= 122 ) {
317
- const upperCaseValue = 65 + ((value - 97) );
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(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');
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 === 0 ) {
366
+ if (scanCode === ScanCode.None) {
365
367
  continue;
366
368
  }
367
- if (IMMUTABLE_CODE_TO_KEY_CODE[scanCode] !== -1 ) {
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 >= 97 && value <= 122 ) {
386
- const upperCaseValue = 65 + ((value - 97) );
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 >= 65 && value <= 90 ) {
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, 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 );
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
- 88 ,
512
- 104
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 = 0 ; scanCode < 193 ; scanCode++) {
518
- if (IMMUTABLE_CODE_TO_KEY_CODE[scanCode] !== -1 ) {
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: -1 ,
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 === 3 ) {
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 === 2 ) {
625
+ if (this._OS === OperatingSystem.Macintosh) {
630
626
  switch (chord.scanCode) {
631
- case 86 :
627
+ case ScanCode.ArrowLeft:
632
628
  return '←';
633
- case 88 :
629
+ case ScanCode.ArrowUp:
634
630
  return '↑';
635
- case 85 :
631
+ case ScanCode.ArrowRight:
636
632
  return '→';
637
- case 87 :
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 !== -1 ) {
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 !== -1 ) {
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 !== -1 ) {
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 === 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) );
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 !== -1 ) {
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 === 94 ) {
754
- code = 46 ;
750
+ if (code === ScanCode.NumpadEnter) {
751
+ code = ScanCode.Enter;
755
752
  }
756
753
  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) )) {
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 !== -1 ) {
766
+ if (immutableScanCode !== ScanCode.DependsOnKbLayout) {
770
767
  code = immutableScanCode;
771
768
  }
772
769
  }
773
770
  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) )) {
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 !== -1 ) {
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 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 ;
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 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 ;
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 = 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);
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 };