@codingame/monaco-vscode-keybindings-service-override 9.0.2 → 10.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.
@@ -1,14 +1,12 @@
1
- import { CharCode } from 'vscode/vscode/vs/base/common/charCode';
2
- import { KeyCodeUtils, KeyCode, ScanCode, IMMUTABLE_CODE_TO_KEY_CODE, ScanCodeUtils, NATIVE_WINDOWS_KEY_CODE_TO_KEY_CODE } from 'vscode/vscode/vs/base/common/keyCodes';
1
+ import { KeyCodeUtils, IMMUTABLE_CODE_TO_KEY_CODE, ScanCodeUtils, NATIVE_WINDOWS_KEY_CODE_TO_KEY_CODE } from 'vscode/vscode/vs/base/common/keyCodes';
3
2
  import { ScanCodeChord, KeyCodeChord } from 'vscode/vscode/vs/base/common/keybindings';
4
3
  import { UILabelProvider } from 'vscode/vscode/vs/base/common/keybindingLabels';
5
- import { OperatingSystem } from 'vscode/vscode/vs/base/common/platform';
6
4
  import { BaseResolvedKeybinding } from 'vscode/vscode/vs/platform/keybinding/common/baseResolvedKeybinding';
7
5
  import { toEmptyArrayIfContainsNull } from 'vscode/vscode/vs/platform/keybinding/common/resolvedKeybindingItem';
8
6
 
9
7
  class WindowsNativeResolvedKeybinding extends BaseResolvedKeybinding {
10
8
  constructor(mapper, chords) {
11
- super(OperatingSystem.Windows, chords);
9
+ super(1 , chords);
12
10
  this._mapper = mapper;
13
11
  }
14
12
  _getLabel(chord) {
@@ -46,10 +44,10 @@ class WindowsNativeResolvedKeybinding extends BaseResolvedKeybinding {
46
44
  return this.__isWYSIWYG(chord.keyCode);
47
45
  }
48
46
  __isWYSIWYG(keyCode) {
49
- if (keyCode === KeyCode.LeftArrow
50
- || keyCode === KeyCode.UpArrow
51
- || keyCode === KeyCode.RightArrow
52
- || keyCode === KeyCode.DownArrow) {
47
+ if (keyCode === 15
48
+ || keyCode === 16
49
+ || keyCode === 17
50
+ || keyCode === 18 ) {
53
51
  return true;
54
52
  }
55
53
  const ariaLabel = this._mapper.getAriaLabelForKeyCode(keyCode);
@@ -77,16 +75,16 @@ class WindowsNativeResolvedKeybinding extends BaseResolvedKeybinding {
77
75
  return result;
78
76
  }
79
77
  _getSingleModifierChordDispatch(chord) {
80
- if (chord.keyCode === KeyCode.Ctrl && !chord.shiftKey && !chord.altKey && !chord.metaKey) {
78
+ if (chord.keyCode === 5 && !chord.shiftKey && !chord.altKey && !chord.metaKey) {
81
79
  return 'ctrl';
82
80
  }
83
- if (chord.keyCode === KeyCode.Shift && !chord.ctrlKey && !chord.altKey && !chord.metaKey) {
81
+ if (chord.keyCode === 4 && !chord.ctrlKey && !chord.altKey && !chord.metaKey) {
84
82
  return 'shift';
85
83
  }
86
- if (chord.keyCode === KeyCode.Alt && !chord.ctrlKey && !chord.shiftKey && !chord.metaKey) {
84
+ if (chord.keyCode === 6 && !chord.ctrlKey && !chord.shiftKey && !chord.metaKey) {
87
85
  return 'alt';
88
86
  }
89
- if (chord.keyCode === KeyCode.Meta && !chord.ctrlKey && !chord.shiftKey && !chord.altKey) {
87
+ if (chord.keyCode === 57 && !chord.ctrlKey && !chord.shiftKey && !chord.altKey) {
90
88
  return 'meta';
91
89
  }
92
90
  return null;
@@ -122,10 +120,10 @@ class WindowsKeyboardMapper {
122
120
  this._scanCodeToKeyCode = [];
123
121
  this._keyCodeToLabel = [];
124
122
  this._keyCodeExists = [];
125
- this._keyCodeToLabel[KeyCode.Unknown] = ( KeyCodeUtils.toString(KeyCode.Unknown));
126
- for (let scanCode = ScanCode.None; scanCode < ScanCode.MAX_VALUE; scanCode++) {
123
+ this._keyCodeToLabel[0 ] = ( KeyCodeUtils.toString(0 ));
124
+ for (let scanCode = 0 ; scanCode < 193 ; scanCode++) {
127
125
  const immutableKeyCode = IMMUTABLE_CODE_TO_KEY_CODE[scanCode];
128
- if (immutableKeyCode !== KeyCode.DependsOnKbLayout) {
126
+ if (immutableKeyCode !== -1 ) {
129
127
  this._scanCodeToKeyCode[scanCode] = immutableKeyCode;
130
128
  this._keyCodeToLabel[immutableKeyCode] = ( KeyCodeUtils.toString(immutableKeyCode));
131
129
  this._keyCodeExists[immutableKeyCode] = true;
@@ -137,17 +135,17 @@ class WindowsKeyboardMapper {
137
135
  for (const strCode in rawMappings) {
138
136
  if (rawMappings.hasOwnProperty(strCode)) {
139
137
  const scanCode = ScanCodeUtils.toEnum(strCode);
140
- if (scanCode === ScanCode.None) {
138
+ if (scanCode === 0 ) {
141
139
  continue;
142
140
  }
143
141
  const rawMapping = rawMappings[strCode];
144
142
  const immutableKeyCode = IMMUTABLE_CODE_TO_KEY_CODE[scanCode];
145
- if (immutableKeyCode !== KeyCode.DependsOnKbLayout) {
146
- const keyCode = NATIVE_WINDOWS_KEY_CODE_TO_KEY_CODE[rawMapping.vkey] || KeyCode.Unknown;
147
- if (keyCode === KeyCode.Unknown || immutableKeyCode === keyCode) {
143
+ if (immutableKeyCode !== -1 ) {
144
+ const keyCode = NATIVE_WINDOWS_KEY_CODE_TO_KEY_CODE[rawMapping.vkey] || 0 ;
145
+ if (keyCode === 0 || immutableKeyCode === keyCode) {
148
146
  continue;
149
147
  }
150
- if (scanCode !== ScanCode.NumpadComma) {
148
+ if (scanCode !== 134 ) {
151
149
  continue;
152
150
  }
153
151
  }
@@ -155,7 +153,7 @@ class WindowsKeyboardMapper {
155
153
  const withShift = rawMapping.withShift;
156
154
  const withAltGr = rawMapping.withAltGr;
157
155
  const withShiftAltGr = rawMapping.withShiftAltGr;
158
- const keyCode = NATIVE_WINDOWS_KEY_CODE_TO_KEY_CODE[rawMapping.vkey] || KeyCode.Unknown;
156
+ const keyCode = NATIVE_WINDOWS_KEY_CODE_TO_KEY_CODE[rawMapping.vkey] || 0 ;
159
157
  const mapping = {
160
158
  scanCode: scanCode,
161
159
  keyCode: keyCode,
@@ -166,7 +164,7 @@ class WindowsKeyboardMapper {
166
164
  };
167
165
  this._codeInfo[scanCode] = mapping;
168
166
  this._scanCodeToKeyCode[scanCode] = keyCode;
169
- if (keyCode === KeyCode.Unknown) {
167
+ if (keyCode === 0 ) {
170
168
  continue;
171
169
  }
172
170
  this._keyCodeExists[keyCode] = true;
@@ -178,13 +176,13 @@ class WindowsKeyboardMapper {
178
176
  }
179
177
  else {
180
178
  const charCode = value.charCodeAt(0);
181
- if (charCode >= CharCode.a && charCode <= CharCode.z) {
182
- const upperCaseValue = CharCode.A + (charCode - CharCode.a);
179
+ if (charCode >= 97 && charCode <= 122 ) {
180
+ const upperCaseValue = 65 + ((charCode - 97) );
183
181
  producesLetter[upperCaseValue] = true;
184
182
  producesLetters = true;
185
- this._keyCodeToLabel[keyCode] = String.fromCharCode(CharCode.A + (charCode - CharCode.a));
183
+ this._keyCodeToLabel[keyCode] = String.fromCharCode(65 + ((charCode - 97) ));
186
184
  }
187
- else if (charCode >= CharCode.A && charCode <= CharCode.Z) {
185
+ else if (charCode >= 65 && charCode <= 90 ) {
188
186
  producesLetter[charCode] = true;
189
187
  producesLetters = true;
190
188
  this._keyCodeToLabel[keyCode] = value;
@@ -200,59 +198,59 @@ class WindowsKeyboardMapper {
200
198
  this._keyCodeToLabel[keyCode] = String.fromCharCode(charCode);
201
199
  }
202
200
  };
203
- _registerLetterIfMissing(CharCode.A, KeyCode.KeyA);
204
- _registerLetterIfMissing(CharCode.B, KeyCode.KeyB);
205
- _registerLetterIfMissing(CharCode.C, KeyCode.KeyC);
206
- _registerLetterIfMissing(CharCode.D, KeyCode.KeyD);
207
- _registerLetterIfMissing(CharCode.E, KeyCode.KeyE);
208
- _registerLetterIfMissing(CharCode.F, KeyCode.KeyF);
209
- _registerLetterIfMissing(CharCode.G, KeyCode.KeyG);
210
- _registerLetterIfMissing(CharCode.H, KeyCode.KeyH);
211
- _registerLetterIfMissing(CharCode.I, KeyCode.KeyI);
212
- _registerLetterIfMissing(CharCode.J, KeyCode.KeyJ);
213
- _registerLetterIfMissing(CharCode.K, KeyCode.KeyK);
214
- _registerLetterIfMissing(CharCode.L, KeyCode.KeyL);
215
- _registerLetterIfMissing(CharCode.M, KeyCode.KeyM);
216
- _registerLetterIfMissing(CharCode.N, KeyCode.KeyN);
217
- _registerLetterIfMissing(CharCode.O, KeyCode.KeyO);
218
- _registerLetterIfMissing(CharCode.P, KeyCode.KeyP);
219
- _registerLetterIfMissing(CharCode.Q, KeyCode.KeyQ);
220
- _registerLetterIfMissing(CharCode.R, KeyCode.KeyR);
221
- _registerLetterIfMissing(CharCode.S, KeyCode.KeyS);
222
- _registerLetterIfMissing(CharCode.T, KeyCode.KeyT);
223
- _registerLetterIfMissing(CharCode.U, KeyCode.KeyU);
224
- _registerLetterIfMissing(CharCode.V, KeyCode.KeyV);
225
- _registerLetterIfMissing(CharCode.W, KeyCode.KeyW);
226
- _registerLetterIfMissing(CharCode.X, KeyCode.KeyX);
227
- _registerLetterIfMissing(CharCode.Y, KeyCode.KeyY);
228
- _registerLetterIfMissing(CharCode.Z, KeyCode.KeyZ);
201
+ _registerLetterIfMissing(65 , 31 );
202
+ _registerLetterIfMissing(66 , 32 );
203
+ _registerLetterIfMissing(67 , 33 );
204
+ _registerLetterIfMissing(68 , 34 );
205
+ _registerLetterIfMissing(69 , 35 );
206
+ _registerLetterIfMissing(70 , 36 );
207
+ _registerLetterIfMissing(71 , 37 );
208
+ _registerLetterIfMissing(72 , 38 );
209
+ _registerLetterIfMissing(73 , 39 );
210
+ _registerLetterIfMissing(74 , 40 );
211
+ _registerLetterIfMissing(75 , 41 );
212
+ _registerLetterIfMissing(76 , 42 );
213
+ _registerLetterIfMissing(77 , 43 );
214
+ _registerLetterIfMissing(78 , 44 );
215
+ _registerLetterIfMissing(79 , 45 );
216
+ _registerLetterIfMissing(80 , 46 );
217
+ _registerLetterIfMissing(81 , 47 );
218
+ _registerLetterIfMissing(82 , 48 );
219
+ _registerLetterIfMissing(83 , 49 );
220
+ _registerLetterIfMissing(84 , 50 );
221
+ _registerLetterIfMissing(85 , 51 );
222
+ _registerLetterIfMissing(86 , 52 );
223
+ _registerLetterIfMissing(87 , 53 );
224
+ _registerLetterIfMissing(88 , 54 );
225
+ _registerLetterIfMissing(89 , 55 );
226
+ _registerLetterIfMissing(90 , 56 );
229
227
  if (!producesLetters) {
230
228
  const _registerLabel = (keyCode, charCode) => {
231
229
  this._keyCodeToLabel[keyCode] = String.fromCharCode(charCode);
232
230
  };
233
- _registerLabel(KeyCode.Semicolon, CharCode.Semicolon);
234
- _registerLabel(KeyCode.Equal, CharCode.Equals);
235
- _registerLabel(KeyCode.Comma, CharCode.Comma);
236
- _registerLabel(KeyCode.Minus, CharCode.Dash);
237
- _registerLabel(KeyCode.Period, CharCode.Period);
238
- _registerLabel(KeyCode.Slash, CharCode.Slash);
239
- _registerLabel(KeyCode.Backquote, CharCode.BackTick);
240
- _registerLabel(KeyCode.BracketLeft, CharCode.OpenSquareBracket);
241
- _registerLabel(KeyCode.Backslash, CharCode.Backslash);
242
- _registerLabel(KeyCode.BracketRight, CharCode.CloseSquareBracket);
243
- _registerLabel(KeyCode.Quote, CharCode.SingleQuote);
231
+ _registerLabel(85 , 59 );
232
+ _registerLabel(86 , 61 );
233
+ _registerLabel(87 , 44 );
234
+ _registerLabel(88 , 45 );
235
+ _registerLabel(89 , 46 );
236
+ _registerLabel(90 , 47 );
237
+ _registerLabel(91 , 96 );
238
+ _registerLabel(92 , 91 );
239
+ _registerLabel(93 , 92 );
240
+ _registerLabel(94 , 93 );
241
+ _registerLabel(95 , 39 );
244
242
  }
245
243
  }
246
244
  dumpDebugInfo() {
247
245
  const result = [];
248
246
  const immutableSamples = [
249
- ScanCode.ArrowUp,
250
- ScanCode.Numpad0
247
+ 88 ,
248
+ 104
251
249
  ];
252
250
  let cnt = 0;
253
251
  result.push(`-----------------------------------------------------------------------------------------------------------------------------------------`);
254
- for (let scanCode = ScanCode.None; scanCode < ScanCode.MAX_VALUE; scanCode++) {
255
- if (IMMUTABLE_CODE_TO_KEY_CODE[scanCode] !== KeyCode.DependsOnKbLayout) {
252
+ for (let scanCode = 0 ; scanCode < 193 ; scanCode++) {
253
+ if (IMMUTABLE_CODE_TO_KEY_CODE[scanCode] !== -1 ) {
256
254
  if (immutableSamples.indexOf(scanCode) === -1) {
257
255
  continue;
258
256
  }
@@ -312,7 +310,7 @@ class WindowsKeyboardMapper {
312
310
  return KeyCodeUtils.toElectronAccelerator(chord.keyCode);
313
311
  }
314
312
  _getLabelForKeyCode(keyCode) {
315
- return this._keyCodeToLabel[keyCode] || ( KeyCodeUtils.toString(KeyCode.Unknown));
313
+ return this._keyCodeToLabel[keyCode] || ( KeyCodeUtils.toString(0 ));
316
314
  }
317
315
  resolveKeyboardEvent(keyboardEvent) {
318
316
  const ctrlKey = keyboardEvent.ctrlKey || (this._mapAltGrToCtrlAlt && keyboardEvent.altGraphKey);
@@ -336,8 +334,8 @@ class WindowsKeyboardMapper {
336
334
  }
337
335
  return chord;
338
336
  }
339
- const keyCode = this._scanCodeToKeyCode[chord.scanCode] || KeyCode.Unknown;
340
- if (keyCode === KeyCode.Unknown || !this._keyCodeExists[keyCode]) {
337
+ const keyCode = this._scanCodeToKeyCode[chord.scanCode] || 0 ;
338
+ if (keyCode === 0 || !this._keyCodeExists[keyCode]) {
341
339
  return null;
342
340
  }
343
341
  return ( new KeyCodeChord(chord.ctrlKey, chord.shiftKey, chord.altKey, chord.metaKey, keyCode));