@codingame/monaco-vscode-api 1.69.13 → 1.69.15

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,7 +1,7 @@
1
- import { h as index, _ as __decorate, a as __param, j as flatten, E as Emitter } from './workspace.js';
2
- import { j as parse } from './polyfill.js';
3
- import { i as isProposedApiEnabled, E as ExtensionsRegistry, h as ExtensionMessageCollector, I as IExtensionService, j as IPreferencesService, k as IUserDataProfileService, l as IKeyboardLayoutService } from './missing-services.js';
4
- import { KeyCodeUtils, IMMUTABLE_CODE_TO_KEY_CODE } from 'monaco-editor/esm/vs/base/common/keyCodes.js';
1
+ import { h as index, _ as __decorate, a as __param, E as Emitter, j as flatten } from './workspace.js';
2
+ import { j as parse, k as getNodeType } from './polyfill.js';
3
+ import { i as isProposedApiEnabled, E as ExtensionsRegistry, h as ExtensionMessageCollector, j as IKeyboardLayoutService, I as IExtensionService, k as IPreferencesService, l as getKeyboardLayoutId, m as IUserDataProfileService, M as MacLinuxFallbackKeyboardMapper } from './missing-services.js';
4
+ import { KeyCodeUtils, IMMUTABLE_CODE_TO_KEY_CODE, NATIVE_WINDOWS_KEY_CODE_TO_KEY_CODE, IMMUTABLE_KEY_CODE_TO_CODE } from 'monaco-editor/esm/vs/base/common/keyCodes.js';
5
5
  import { SimpleKeybinding, ScanCodeBinding, ChordKeybinding } from 'monaco-editor/esm/vs/base/common/keybindings.js';
6
6
  import { ContextKeyExpr, IContextKeyService } from 'monaco-editor/esm/vs/platform/contextkey/common/contextkey.js';
7
7
  import { S as Services, q as IUserDataProfilesService, i as IFileService, I as IEditorService, b as IEditorGroupsService, o as IHostService } from './services2.js';
@@ -19,10 +19,10 @@ import { AbstractKeybindingService } from 'monaco-editor/esm/vs/platform/keybind
19
19
  import { KeybindingsRegistry } from 'monaco-editor/esm/vs/platform/keybinding/common/keybindingsRegistry.js';
20
20
  import { addDisposableListener, EventType } from 'monaco-editor/esm/vs/base/browser/dom.js';
21
21
  import { BrowserFeatures } from 'monaco-editor/esm/vs/base/browser/canIUse.js';
22
- import { UserSettingsLabelProvider } from 'monaco-editor/esm/vs/base/common/keybindingLabels.js';
23
- import { OS, isMacintosh } from 'monaco-editor/esm/vs/base/common/platform.js';
22
+ import { UserSettingsLabelProvider, UILabelProvider } from 'monaco-editor/esm/vs/base/common/keybindingLabels.js';
23
+ import { OS, isMacintosh, isWindows, isLinux } from 'monaco-editor/esm/vs/base/common/platform.js';
24
24
  import { KeybindingResolver } from 'monaco-editor/esm/vs/platform/keybinding/common/keybindingResolver.js';
25
- import { ResolvedKeybindingItem } from 'monaco-editor/esm/vs/platform/keybinding/common/resolvedKeybindingItem.js';
25
+ import { ResolvedKeybindingItem, removeElementsAfterNulls } from 'monaco-editor/esm/vs/platform/keybinding/common/resolvedKeybindingItem.js';
26
26
  import { ITelemetryService } from 'monaco-editor/esm/vs/platform/telemetry/common/telemetry.js';
27
27
  import { INotificationService } from 'monaco-editor/esm/vs/platform/notification/common/notification.js';
28
28
  import { IConfigurationService } from 'monaco-editor/esm/vs/platform/configuration/common/configuration.js';
@@ -43,6 +43,9 @@ import { stripIcons } from 'monaco-editor/esm/vs/base/common/iconLabels.js';
43
43
  import { IInstantiationService } from 'monaco-editor/esm/vs/platform/instantiation/common/instantiation.js';
44
44
  import { IKeybindingService } from 'monaco-editor/esm/vs/platform/keybinding/common/keybinding.js';
45
45
  import { IDialogService } from 'monaco-editor/esm/vs/platform/dialogs/common/dialogs.js';
46
+ import { IStorageService } from 'monaco-editor/esm/vs/platform/storage/common/storage.js';
47
+ import { BaseResolvedKeybinding } from 'monaco-editor/esm/vs/platform/keybinding/common/baseResolvedKeybinding.js';
48
+ import { IEnvironmentService } from 'monaco-editor/esm/vs/platform/environment/common/environment.js';
46
49
  import { g as getServiceOverride$1 } from './files.js';
47
50
  import { g as getExtensionPoint, c as consoleExtensionMessageHandler } from './tools.js';
48
51
  import { bd as DEFAULT_EXTENSION } from './extHost.js';
@@ -209,6 +212,26 @@ const isChrome = !!(userAgent && userAgent.indexOf('Chrome') >= 0);
209
212
  !!(!isChrome && (userAgent && userAgent.indexOf('Safari') >= 0));
210
213
  !!(userAgent && userAgent.indexOf('Edg/') >= 0);
211
214
  !!(userAgent && userAgent.indexOf('Android') >= 0);
215
+ class KeyCodeStrMap {
216
+ constructor() {
217
+ this._keyCodeToStr = [];
218
+ this._strToKeyCode = Object.create(null);
219
+ }
220
+ define(keyCode, str) {
221
+ this._keyCodeToStr[keyCode] = str;
222
+ this._strToKeyCode[str.toLowerCase()] = keyCode;
223
+ }
224
+ keyCodeToStr(keyCode) {
225
+ return this._keyCodeToStr[keyCode];
226
+ }
227
+ strToKeyCode(str) {
228
+ return this._strToKeyCode[str.toLowerCase()] || 0 ;
229
+ }
230
+ }
231
+ const uiMap = ( (new KeyCodeStrMap()));
232
+ const userSettingsUSMap = ( (new KeyCodeStrMap()));
233
+ const userSettingsGeneralMap = ( (new KeyCodeStrMap()));
234
+ const EVENT_KEY_CODE_MAP = ( (new Array(230)));
212
235
  const scanCodeIntToStr = [];
213
236
  const scanCodeStrToInt = Object.create(null);
214
237
  const scanCodeLowerCaseStrToInt = Object.create(null);
@@ -217,6 +240,263 @@ const ScanCodeUtils = {
217
240
  toEnum: (scanCode) => scanCodeStrToInt[scanCode] || 0 ,
218
241
  toString: (scanCode) => scanCodeIntToStr[scanCode] || 'None'
219
242
  };
243
+ (function () {
244
+ const empty = '';
245
+ const mappings = [
246
+ [0, 1, 0 , 'None', 0 , 'unknown', 0, 'VK_UNKNOWN', empty, empty],
247
+ [0, 1, 1 , 'Hyper', 0 , empty, 0, empty, empty, empty],
248
+ [0, 1, 2 , 'Super', 0 , empty, 0, empty, empty, empty],
249
+ [0, 1, 3 , 'Fn', 0 , empty, 0, empty, empty, empty],
250
+ [0, 1, 4 , 'FnLock', 0 , empty, 0, empty, empty, empty],
251
+ [0, 1, 5 , 'Suspend', 0 , empty, 0, empty, empty, empty],
252
+ [0, 1, 6 , 'Resume', 0 , empty, 0, empty, empty, empty],
253
+ [0, 1, 7 , 'Turbo', 0 , empty, 0, empty, empty, empty],
254
+ [0, 1, 8 , 'Sleep', 0 , empty, 0, 'VK_SLEEP', empty, empty],
255
+ [0, 1, 9 , 'WakeUp', 0 , empty, 0, empty, empty, empty],
256
+ [31, 0, 10 , 'KeyA', 31 , 'A', 65, 'VK_A', empty, empty],
257
+ [32, 0, 11 , 'KeyB', 32 , 'B', 66, 'VK_B', empty, empty],
258
+ [33, 0, 12 , 'KeyC', 33 , 'C', 67, 'VK_C', empty, empty],
259
+ [34, 0, 13 , 'KeyD', 34 , 'D', 68, 'VK_D', empty, empty],
260
+ [35, 0, 14 , 'KeyE', 35 , 'E', 69, 'VK_E', empty, empty],
261
+ [36, 0, 15 , 'KeyF', 36 , 'F', 70, 'VK_F', empty, empty],
262
+ [37, 0, 16 , 'KeyG', 37 , 'G', 71, 'VK_G', empty, empty],
263
+ [38, 0, 17 , 'KeyH', 38 , 'H', 72, 'VK_H', empty, empty],
264
+ [39, 0, 18 , 'KeyI', 39 , 'I', 73, 'VK_I', empty, empty],
265
+ [40, 0, 19 , 'KeyJ', 40 , 'J', 74, 'VK_J', empty, empty],
266
+ [41, 0, 20 , 'KeyK', 41 , 'K', 75, 'VK_K', empty, empty],
267
+ [42, 0, 21 , 'KeyL', 42 , 'L', 76, 'VK_L', empty, empty],
268
+ [43, 0, 22 , 'KeyM', 43 , 'M', 77, 'VK_M', empty, empty],
269
+ [44, 0, 23 , 'KeyN', 44 , 'N', 78, 'VK_N', empty, empty],
270
+ [45, 0, 24 , 'KeyO', 45 , 'O', 79, 'VK_O', empty, empty],
271
+ [46, 0, 25 , 'KeyP', 46 , 'P', 80, 'VK_P', empty, empty],
272
+ [47, 0, 26 , 'KeyQ', 47 , 'Q', 81, 'VK_Q', empty, empty],
273
+ [48, 0, 27 , 'KeyR', 48 , 'R', 82, 'VK_R', empty, empty],
274
+ [49, 0, 28 , 'KeyS', 49 , 'S', 83, 'VK_S', empty, empty],
275
+ [50, 0, 29 , 'KeyT', 50 , 'T', 84, 'VK_T', empty, empty],
276
+ [51, 0, 30 , 'KeyU', 51 , 'U', 85, 'VK_U', empty, empty],
277
+ [52, 0, 31 , 'KeyV', 52 , 'V', 86, 'VK_V', empty, empty],
278
+ [53, 0, 32 , 'KeyW', 53 , 'W', 87, 'VK_W', empty, empty],
279
+ [54, 0, 33 , 'KeyX', 54 , 'X', 88, 'VK_X', empty, empty],
280
+ [55, 0, 34 , 'KeyY', 55 , 'Y', 89, 'VK_Y', empty, empty],
281
+ [56, 0, 35 , 'KeyZ', 56 , 'Z', 90, 'VK_Z', empty, empty],
282
+ [22, 0, 36 , 'Digit1', 22 , '1', 49, 'VK_1', empty, empty],
283
+ [23, 0, 37 , 'Digit2', 23 , '2', 50, 'VK_2', empty, empty],
284
+ [24, 0, 38 , 'Digit3', 24 , '3', 51, 'VK_3', empty, empty],
285
+ [25, 0, 39 , 'Digit4', 25 , '4', 52, 'VK_4', empty, empty],
286
+ [26, 0, 40 , 'Digit5', 26 , '5', 53, 'VK_5', empty, empty],
287
+ [27, 0, 41 , 'Digit6', 27 , '6', 54, 'VK_6', empty, empty],
288
+ [28, 0, 42 , 'Digit7', 28 , '7', 55, 'VK_7', empty, empty],
289
+ [29, 0, 43 , 'Digit8', 29 , '8', 56, 'VK_8', empty, empty],
290
+ [30, 0, 44 , 'Digit9', 30 , '9', 57, 'VK_9', empty, empty],
291
+ [21, 0, 45 , 'Digit0', 21 , '0', 48, 'VK_0', empty, empty],
292
+ [3, 1, 46 , 'Enter', 3 , 'Enter', 13, 'VK_RETURN', empty, empty],
293
+ [9, 1, 47 , 'Escape', 9 , 'Escape', 27, 'VK_ESCAPE', empty, empty],
294
+ [1, 1, 48 , 'Backspace', 1 , 'Backspace', 8, 'VK_BACK', empty, empty],
295
+ [2, 1, 49 , 'Tab', 2 , 'Tab', 9, 'VK_TAB', empty, empty],
296
+ [10, 1, 50 , 'Space', 10 , 'Space', 32, 'VK_SPACE', empty, empty],
297
+ [83, 0, 51 , 'Minus', 83 , '-', 189, 'VK_OEM_MINUS', '-', 'OEM_MINUS'],
298
+ [81, 0, 52 , 'Equal', 81 , '=', 187, 'VK_OEM_PLUS', '=', 'OEM_PLUS'],
299
+ [87, 0, 53 , 'BracketLeft', 87 , '[', 219, 'VK_OEM_4', '[', 'OEM_4'],
300
+ [89, 0, 54 , 'BracketRight', 89 , ']', 221, 'VK_OEM_6', ']', 'OEM_6'],
301
+ [88, 0, 55 , 'Backslash', 88 , '\\', 220, 'VK_OEM_5', '\\', 'OEM_5'],
302
+ [0, 0, 56 , 'IntlHash', 0 , empty, 0, empty, empty, empty],
303
+ [80, 0, 57 , 'Semicolon', 80 , ';', 186, 'VK_OEM_1', ';', 'OEM_1'],
304
+ [90, 0, 58 , 'Quote', 90 , '\'', 222, 'VK_OEM_7', '\'', 'OEM_7'],
305
+ [86, 0, 59 , 'Backquote', 86 , '`', 192, 'VK_OEM_3', '`', 'OEM_3'],
306
+ [82, 0, 60 , 'Comma', 82 , ',', 188, 'VK_OEM_COMMA', ',', 'OEM_COMMA'],
307
+ [84, 0, 61 , 'Period', 84 , '.', 190, 'VK_OEM_PERIOD', '.', 'OEM_PERIOD'],
308
+ [85, 0, 62 , 'Slash', 85 , '/', 191, 'VK_OEM_2', '/', 'OEM_2'],
309
+ [8, 1, 63 , 'CapsLock', 8 , 'CapsLock', 20, 'VK_CAPITAL', empty, empty],
310
+ [59, 1, 64 , 'F1', 59 , 'F1', 112, 'VK_F1', empty, empty],
311
+ [60, 1, 65 , 'F2', 60 , 'F2', 113, 'VK_F2', empty, empty],
312
+ [61, 1, 66 , 'F3', 61 , 'F3', 114, 'VK_F3', empty, empty],
313
+ [62, 1, 67 , 'F4', 62 , 'F4', 115, 'VK_F4', empty, empty],
314
+ [63, 1, 68 , 'F5', 63 , 'F5', 116, 'VK_F5', empty, empty],
315
+ [64, 1, 69 , 'F6', 64 , 'F6', 117, 'VK_F6', empty, empty],
316
+ [65, 1, 70 , 'F7', 65 , 'F7', 118, 'VK_F7', empty, empty],
317
+ [66, 1, 71 , 'F8', 66 , 'F8', 119, 'VK_F8', empty, empty],
318
+ [67, 1, 72 , 'F9', 67 , 'F9', 120, 'VK_F9', empty, empty],
319
+ [68, 1, 73 , 'F10', 68 , 'F10', 121, 'VK_F10', empty, empty],
320
+ [69, 1, 74 , 'F11', 69 , 'F11', 122, 'VK_F11', empty, empty],
321
+ [70, 1, 75 , 'F12', 70 , 'F12', 123, 'VK_F12', empty, empty],
322
+ [0, 1, 76 , 'PrintScreen', 0 , empty, 0, empty, empty, empty],
323
+ [79, 1, 77 , 'ScrollLock', 79 , 'ScrollLock', 145, 'VK_SCROLL', empty, empty],
324
+ [7, 1, 78 , 'Pause', 7 , 'PauseBreak', 19, 'VK_PAUSE', empty, empty],
325
+ [19, 1, 79 , 'Insert', 19 , 'Insert', 45, 'VK_INSERT', empty, empty],
326
+ [14, 1, 80 , 'Home', 14 , 'Home', 36, 'VK_HOME', empty, empty],
327
+ [11, 1, 81 , 'PageUp', 11 , 'PageUp', 33, 'VK_PRIOR', empty, empty],
328
+ [20, 1, 82 , 'Delete', 20 , 'Delete', 46, 'VK_DELETE', empty, empty],
329
+ [13, 1, 83 , 'End', 13 , 'End', 35, 'VK_END', empty, empty],
330
+ [12, 1, 84 , 'PageDown', 12 , 'PageDown', 34, 'VK_NEXT', empty, empty],
331
+ [17, 1, 85 , 'ArrowRight', 17 , 'RightArrow', 39, 'VK_RIGHT', 'Right', empty],
332
+ [15, 1, 86 , 'ArrowLeft', 15 , 'LeftArrow', 37, 'VK_LEFT', 'Left', empty],
333
+ [18, 1, 87 , 'ArrowDown', 18 , 'DownArrow', 40, 'VK_DOWN', 'Down', empty],
334
+ [16, 1, 88 , 'ArrowUp', 16 , 'UpArrow', 38, 'VK_UP', 'Up', empty],
335
+ [78, 1, 89 , 'NumLock', 78 , 'NumLock', 144, 'VK_NUMLOCK', empty, empty],
336
+ [108, 1, 90 , 'NumpadDivide', 108 , 'NumPad_Divide', 111, 'VK_DIVIDE', empty, empty],
337
+ [103, 1, 91 , 'NumpadMultiply', 103 , 'NumPad_Multiply', 106, 'VK_MULTIPLY', empty, empty],
338
+ [106, 1, 92 , 'NumpadSubtract', 106 , 'NumPad_Subtract', 109, 'VK_SUBTRACT', empty, empty],
339
+ [104, 1, 93 , 'NumpadAdd', 104 , 'NumPad_Add', 107, 'VK_ADD', empty, empty],
340
+ [3, 1, 94 , 'NumpadEnter', 3 , empty, 0, empty, empty, empty],
341
+ [94, 1, 95 , 'Numpad1', 94 , 'NumPad1', 97, 'VK_NUMPAD1', empty, empty],
342
+ [95, 1, 96 , 'Numpad2', 95 , 'NumPad2', 98, 'VK_NUMPAD2', empty, empty],
343
+ [96, 1, 97 , 'Numpad3', 96 , 'NumPad3', 99, 'VK_NUMPAD3', empty, empty],
344
+ [97, 1, 98 , 'Numpad4', 97 , 'NumPad4', 100, 'VK_NUMPAD4', empty, empty],
345
+ [98, 1, 99 , 'Numpad5', 98 , 'NumPad5', 101, 'VK_NUMPAD5', empty, empty],
346
+ [99, 1, 100 , 'Numpad6', 99 , 'NumPad6', 102, 'VK_NUMPAD6', empty, empty],
347
+ [100, 1, 101 , 'Numpad7', 100 , 'NumPad7', 103, 'VK_NUMPAD7', empty, empty],
348
+ [101, 1, 102 , 'Numpad8', 101 , 'NumPad8', 104, 'VK_NUMPAD8', empty, empty],
349
+ [102, 1, 103 , 'Numpad9', 102 , 'NumPad9', 105, 'VK_NUMPAD9', empty, empty],
350
+ [93, 1, 104 , 'Numpad0', 93 , 'NumPad0', 96, 'VK_NUMPAD0', empty, empty],
351
+ [107, 1, 105 , 'NumpadDecimal', 107 , 'NumPad_Decimal', 110, 'VK_DECIMAL', empty, empty],
352
+ [92, 0, 106 , 'IntlBackslash', 92 , 'OEM_102', 226, 'VK_OEM_102', empty, empty],
353
+ [58, 1, 107 , 'ContextMenu', 58 , 'ContextMenu', 93, empty, empty, empty],
354
+ [0, 1, 108 , 'Power', 0 , empty, 0, empty, empty, empty],
355
+ [0, 1, 109 , 'NumpadEqual', 0 , empty, 0, empty, empty, empty],
356
+ [71, 1, 110 , 'F13', 71 , 'F13', 124, 'VK_F13', empty, empty],
357
+ [72, 1, 111 , 'F14', 72 , 'F14', 125, 'VK_F14', empty, empty],
358
+ [73, 1, 112 , 'F15', 73 , 'F15', 126, 'VK_F15', empty, empty],
359
+ [74, 1, 113 , 'F16', 74 , 'F16', 127, 'VK_F16', empty, empty],
360
+ [75, 1, 114 , 'F17', 75 , 'F17', 128, 'VK_F17', empty, empty],
361
+ [76, 1, 115 , 'F18', 76 , 'F18', 129, 'VK_F18', empty, empty],
362
+ [77, 1, 116 , 'F19', 77 , 'F19', 130, 'VK_F19', empty, empty],
363
+ [0, 1, 117 , 'F20', 0 , empty, 0, 'VK_F20', empty, empty],
364
+ [0, 1, 118 , 'F21', 0 , empty, 0, 'VK_F21', empty, empty],
365
+ [0, 1, 119 , 'F22', 0 , empty, 0, 'VK_F22', empty, empty],
366
+ [0, 1, 120 , 'F23', 0 , empty, 0, 'VK_F23', empty, empty],
367
+ [0, 1, 121 , 'F24', 0 , empty, 0, 'VK_F24', empty, empty],
368
+ [0, 1, 122 , 'Open', 0 , empty, 0, empty, empty, empty],
369
+ [0, 1, 123 , 'Help', 0 , empty, 0, empty, empty, empty],
370
+ [0, 1, 124 , 'Select', 0 , empty, 0, empty, empty, empty],
371
+ [0, 1, 125 , 'Again', 0 , empty, 0, empty, empty, empty],
372
+ [0, 1, 126 , 'Undo', 0 , empty, 0, empty, empty, empty],
373
+ [0, 1, 127 , 'Cut', 0 , empty, 0, empty, empty, empty],
374
+ [0, 1, 128 , 'Copy', 0 , empty, 0, empty, empty, empty],
375
+ [0, 1, 129 , 'Paste', 0 , empty, 0, empty, empty, empty],
376
+ [0, 1, 130 , 'Find', 0 , empty, 0, empty, empty, empty],
377
+ [0, 1, 131 , 'AudioVolumeMute', 112 , 'AudioVolumeMute', 173, 'VK_VOLUME_MUTE', empty, empty],
378
+ [0, 1, 132 , 'AudioVolumeUp', 113 , 'AudioVolumeUp', 175, 'VK_VOLUME_UP', empty, empty],
379
+ [0, 1, 133 , 'AudioVolumeDown', 114 , 'AudioVolumeDown', 174, 'VK_VOLUME_DOWN', empty, empty],
380
+ [105, 1, 134 , 'NumpadComma', 105 , 'NumPad_Separator', 108, 'VK_SEPARATOR', empty, empty],
381
+ [110, 0, 135 , 'IntlRo', 110 , 'ABNT_C1', 193, 'VK_ABNT_C1', empty, empty],
382
+ [0, 1, 136 , 'KanaMode', 0 , empty, 0, empty, empty, empty],
383
+ [0, 0, 137 , 'IntlYen', 0 , empty, 0, empty, empty, empty],
384
+ [0, 1, 138 , 'Convert', 0 , empty, 0, empty, empty, empty],
385
+ [0, 1, 139 , 'NonConvert', 0 , empty, 0, empty, empty, empty],
386
+ [0, 1, 140 , 'Lang1', 0 , empty, 0, empty, empty, empty],
387
+ [0, 1, 141 , 'Lang2', 0 , empty, 0, empty, empty, empty],
388
+ [0, 1, 142 , 'Lang3', 0 , empty, 0, empty, empty, empty],
389
+ [0, 1, 143 , 'Lang4', 0 , empty, 0, empty, empty, empty],
390
+ [0, 1, 144 , 'Lang5', 0 , empty, 0, empty, empty, empty],
391
+ [0, 1, 145 , 'Abort', 0 , empty, 0, empty, empty, empty],
392
+ [0, 1, 146 , 'Props', 0 , empty, 0, empty, empty, empty],
393
+ [0, 1, 147 , 'NumpadParenLeft', 0 , empty, 0, empty, empty, empty],
394
+ [0, 1, 148 , 'NumpadParenRight', 0 , empty, 0, empty, empty, empty],
395
+ [0, 1, 149 , 'NumpadBackspace', 0 , empty, 0, empty, empty, empty],
396
+ [0, 1, 150 , 'NumpadMemoryStore', 0 , empty, 0, empty, empty, empty],
397
+ [0, 1, 151 , 'NumpadMemoryRecall', 0 , empty, 0, empty, empty, empty],
398
+ [0, 1, 152 , 'NumpadMemoryClear', 0 , empty, 0, empty, empty, empty],
399
+ [0, 1, 153 , 'NumpadMemoryAdd', 0 , empty, 0, empty, empty, empty],
400
+ [0, 1, 154 , 'NumpadMemorySubtract', 0 , empty, 0, empty, empty, empty],
401
+ [0, 1, 155 , 'NumpadClear', 126 , 'Clear', 12, 'VK_CLEAR', empty, empty],
402
+ [0, 1, 156 , 'NumpadClearEntry', 0 , empty, 0, empty, empty, empty],
403
+ [5, 1, 0 , empty, 5 , 'Ctrl', 17, 'VK_CONTROL', empty, empty],
404
+ [4, 1, 0 , empty, 4 , 'Shift', 16, 'VK_SHIFT', empty, empty],
405
+ [6, 1, 0 , empty, 6 , 'Alt', 18, 'VK_MENU', empty, empty],
406
+ [57, 1, 0 , empty, 57 , 'Meta', 0, 'VK_COMMAND', empty, empty],
407
+ [5, 1, 157 , 'ControlLeft', 5 , empty, 0, 'VK_LCONTROL', empty, empty],
408
+ [4, 1, 158 , 'ShiftLeft', 4 , empty, 0, 'VK_LSHIFT', empty, empty],
409
+ [6, 1, 159 , 'AltLeft', 6 , empty, 0, 'VK_LMENU', empty, empty],
410
+ [57, 1, 160 , 'MetaLeft', 57 , empty, 0, 'VK_LWIN', empty, empty],
411
+ [5, 1, 161 , 'ControlRight', 5 , empty, 0, 'VK_RCONTROL', empty, empty],
412
+ [4, 1, 162 , 'ShiftRight', 4 , empty, 0, 'VK_RSHIFT', empty, empty],
413
+ [6, 1, 163 , 'AltRight', 6 , empty, 0, 'VK_RMENU', empty, empty],
414
+ [57, 1, 164 , 'MetaRight', 57 , empty, 0, 'VK_RWIN', empty, empty],
415
+ [0, 1, 165 , 'BrightnessUp', 0 , empty, 0, empty, empty, empty],
416
+ [0, 1, 166 , 'BrightnessDown', 0 , empty, 0, empty, empty, empty],
417
+ [0, 1, 167 , 'MediaPlay', 0 , empty, 0, empty, empty, empty],
418
+ [0, 1, 168 , 'MediaRecord', 0 , empty, 0, empty, empty, empty],
419
+ [0, 1, 169 , 'MediaFastForward', 0 , empty, 0, empty, empty, empty],
420
+ [0, 1, 170 , 'MediaRewind', 0 , empty, 0, empty, empty, empty],
421
+ [114, 1, 171 , 'MediaTrackNext', 119 , 'MediaTrackNext', 176, 'VK_MEDIA_NEXT_TRACK', empty, empty],
422
+ [115, 1, 172 , 'MediaTrackPrevious', 120 , 'MediaTrackPrevious', 177, 'VK_MEDIA_PREV_TRACK', empty, empty],
423
+ [116, 1, 173 , 'MediaStop', 121 , 'MediaStop', 178, 'VK_MEDIA_STOP', empty, empty],
424
+ [0, 1, 174 , 'Eject', 0 , empty, 0, empty, empty, empty],
425
+ [117, 1, 175 , 'MediaPlayPause', 122 , 'MediaPlayPause', 179, 'VK_MEDIA_PLAY_PAUSE', empty, empty],
426
+ [0, 1, 176 , 'MediaSelect', 123 , 'LaunchMediaPlayer', 181, 'VK_MEDIA_LAUNCH_MEDIA_SELECT', empty, empty],
427
+ [0, 1, 177 , 'LaunchMail', 124 , 'LaunchMail', 180, 'VK_MEDIA_LAUNCH_MAIL', empty, empty],
428
+ [0, 1, 178 , 'LaunchApp2', 125 , 'LaunchApp2', 183, 'VK_MEDIA_LAUNCH_APP2', empty, empty],
429
+ [0, 1, 179 , 'LaunchApp1', 0 , empty, 0, 'VK_MEDIA_LAUNCH_APP1', empty, empty],
430
+ [0, 1, 180 , 'SelectTask', 0 , empty, 0, empty, empty, empty],
431
+ [0, 1, 181 , 'LaunchScreenSaver', 0 , empty, 0, empty, empty, empty],
432
+ [0, 1, 182 , 'BrowserSearch', 115 , 'BrowserSearch', 170, 'VK_BROWSER_SEARCH', empty, empty],
433
+ [0, 1, 183 , 'BrowserHome', 116 , 'BrowserHome', 172, 'VK_BROWSER_HOME', empty, empty],
434
+ [112, 1, 184 , 'BrowserBack', 117 , 'BrowserBack', 166, 'VK_BROWSER_BACK', empty, empty],
435
+ [113, 1, 185 , 'BrowserForward', 118 , 'BrowserForward', 167, 'VK_BROWSER_FORWARD', empty, empty],
436
+ [0, 1, 186 , 'BrowserStop', 0 , empty, 0, 'VK_BROWSER_STOP', empty, empty],
437
+ [0, 1, 187 , 'BrowserRefresh', 0 , empty, 0, 'VK_BROWSER_REFRESH', empty, empty],
438
+ [0, 1, 188 , 'BrowserFavorites', 0 , empty, 0, 'VK_BROWSER_FAVORITES', empty, empty],
439
+ [0, 1, 189 , 'ZoomToggle', 0 , empty, 0, empty, empty, empty],
440
+ [0, 1, 190 , 'MailReply', 0 , empty, 0, empty, empty, empty],
441
+ [0, 1, 191 , 'MailForward', 0 , empty, 0, empty, empty, empty],
442
+ [0, 1, 192 , 'MailSend', 0 , empty, 0, empty, empty, empty],
443
+ [109, 1, 0 , empty, 109 , 'KeyInComposition', 229, empty, empty, empty],
444
+ [111, 1, 0 , empty, 111 , 'ABNT_C2', 194, 'VK_ABNT_C2', empty, empty],
445
+ [91, 1, 0 , empty, 91 , 'OEM_8', 223, 'VK_OEM_8', empty, empty],
446
+ [0, 1, 0 , empty, 0 , empty, 0, 'VK_KANA', empty, empty],
447
+ [0, 1, 0 , empty, 0 , empty, 0, 'VK_HANGUL', empty, empty],
448
+ [0, 1, 0 , empty, 0 , empty, 0, 'VK_JUNJA', empty, empty],
449
+ [0, 1, 0 , empty, 0 , empty, 0, 'VK_FINAL', empty, empty],
450
+ [0, 1, 0 , empty, 0 , empty, 0, 'VK_HANJA', empty, empty],
451
+ [0, 1, 0 , empty, 0 , empty, 0, 'VK_KANJI', empty, empty],
452
+ [0, 1, 0 , empty, 0 , empty, 0, 'VK_CONVERT', empty, empty],
453
+ [0, 1, 0 , empty, 0 , empty, 0, 'VK_NONCONVERT', empty, empty],
454
+ [0, 1, 0 , empty, 0 , empty, 0, 'VK_ACCEPT', empty, empty],
455
+ [0, 1, 0 , empty, 0 , empty, 0, 'VK_MODECHANGE', empty, empty],
456
+ [0, 1, 0 , empty, 0 , empty, 0, 'VK_SELECT', empty, empty],
457
+ [0, 1, 0 , empty, 0 , empty, 0, 'VK_PRINT', empty, empty],
458
+ [0, 1, 0 , empty, 0 , empty, 0, 'VK_EXECUTE', empty, empty],
459
+ [0, 1, 0 , empty, 0 , empty, 0, 'VK_SNAPSHOT', empty, empty],
460
+ [0, 1, 0 , empty, 0 , empty, 0, 'VK_HELP', empty, empty],
461
+ [0, 1, 0 , empty, 0 , empty, 0, 'VK_APPS', empty, empty],
462
+ [0, 1, 0 , empty, 0 , empty, 0, 'VK_PROCESSKEY', empty, empty],
463
+ [0, 1, 0 , empty, 0 , empty, 0, 'VK_PACKET', empty, empty],
464
+ [0, 1, 0 , empty, 0 , empty, 0, 'VK_DBE_SBCSCHAR', empty, empty],
465
+ [0, 1, 0 , empty, 0 , empty, 0, 'VK_DBE_DBCSCHAR', empty, empty],
466
+ [0, 1, 0 , empty, 0 , empty, 0, 'VK_ATTN', empty, empty],
467
+ [0, 1, 0 , empty, 0 , empty, 0, 'VK_CRSEL', empty, empty],
468
+ [0, 1, 0 , empty, 0 , empty, 0, 'VK_EXSEL', empty, empty],
469
+ [0, 1, 0 , empty, 0 , empty, 0, 'VK_EREOF', empty, empty],
470
+ [0, 1, 0 , empty, 0 , empty, 0, 'VK_PLAY', empty, empty],
471
+ [0, 1, 0 , empty, 0 , empty, 0, 'VK_ZOOM', empty, empty],
472
+ [0, 1, 0 , empty, 0 , empty, 0, 'VK_NONAME', empty, empty],
473
+ [0, 1, 0 , empty, 0 , empty, 0, 'VK_PA1', empty, empty],
474
+ [0, 1, 0 , empty, 0 , empty, 0, 'VK_OEM_CLEAR', empty, empty],
475
+ ];
476
+ const seenKeyCode = [];
477
+ const seenScanCode = [];
478
+ for (const mapping of mappings) {
479
+ const [_keyCodeOrd, immutable, scanCode, scanCodeStr, keyCode, keyCodeStr, eventKeyCode, vkey, usUserSettingsLabel, generalUserSettingsLabel] = mapping;
480
+ if (!seenScanCode[scanCode]) {
481
+ seenScanCode[scanCode] = true;
482
+ scanCodeIntToStr[scanCode] = scanCodeStr;
483
+ scanCodeStrToInt[scanCodeStr] = scanCode;
484
+ scanCodeLowerCaseStrToInt[scanCodeStr.toLowerCase()] = scanCode;
485
+ }
486
+ if (!seenKeyCode[keyCode]) {
487
+ seenKeyCode[keyCode] = true;
488
+ if (!keyCodeStr) {
489
+ throw new Error(`String representation missing for key code ${keyCode} around scan code ${scanCodeStr}`);
490
+ }
491
+ uiMap.define(keyCode, keyCodeStr);
492
+ userSettingsUSMap.define(keyCode, usUserSettingsLabel || keyCodeStr);
493
+ userSettingsGeneralMap.define(keyCode, generalUserSettingsLabel || usUserSettingsLabel || keyCodeStr);
494
+ }
495
+ if (eventKeyCode) {
496
+ EVENT_KEY_CODE_MAP[eventKeyCode] = keyCode;
497
+ }
498
+ }
499
+ })();
220
500
  function printKeyboardEvent(e) {
221
501
  const modifiers = [];
222
502
  if (e.ctrlKey) {
@@ -2171,8 +2451,8 @@ function updateSchema(additionalContributions) {
2171
2451
  commandsSchemas.push(...additionalContributions);
2172
2452
  schemaRegistry.notifySchemaChanged(schemaId);
2173
2453
  }
2174
- const configurationRegistry = ( (Registry.as(Extensions$1.Configuration)));
2175
- const keyboardConfiguration = {
2454
+ const configurationRegistry$1 = ( (Registry.as(Extensions$1.Configuration)));
2455
+ const keyboardConfiguration$1 = {
2176
2456
  'id': 'keyboard',
2177
2457
  'order': 15,
2178
2458
  'type': 'object',
@@ -2191,7 +2471,370 @@ const keyboardConfiguration = {
2191
2471
  }
2192
2472
  }
2193
2473
  };
2194
- configurationRegistry.registerConfiguration(keyboardConfiguration);
2474
+ configurationRegistry$1.registerConfiguration(keyboardConfiguration$1);
2475
+ class WindowsNativeResolvedKeybinding extends BaseResolvedKeybinding {
2476
+ constructor(mapper, parts) {
2477
+ super(1 , parts);
2478
+ this._mapper = mapper;
2479
+ }
2480
+ _getLabel(keybinding) {
2481
+ if (keybinding.isDuplicateModifierCase()) {
2482
+ return '';
2483
+ }
2484
+ return this._mapper.getUILabelForKeyCode(keybinding.keyCode);
2485
+ }
2486
+ _getUSLabelForKeybinding(keybinding) {
2487
+ if (keybinding.isDuplicateModifierCase()) {
2488
+ return '';
2489
+ }
2490
+ return (
2491
+ (KeyCodeUtils.toString(keybinding.keyCode))
2492
+ );
2493
+ }
2494
+ getUSLabel() {
2495
+ return UILabelProvider.toLabel(this._os, this._parts, (keybinding) => this._getUSLabelForKeybinding(keybinding));
2496
+ }
2497
+ _getAriaLabel(keybinding) {
2498
+ if (keybinding.isDuplicateModifierCase()) {
2499
+ return '';
2500
+ }
2501
+ return this._mapper.getAriaLabelForKeyCode(keybinding.keyCode);
2502
+ }
2503
+ _getElectronAccelerator(keybinding) {
2504
+ return this._mapper.getElectronAcceleratorForKeyBinding(keybinding);
2505
+ }
2506
+ _getUserSettingsLabel(keybinding) {
2507
+ if (keybinding.isDuplicateModifierCase()) {
2508
+ return '';
2509
+ }
2510
+ const result = this._mapper.getUserSettingsLabelForKeyCode(keybinding.keyCode);
2511
+ return (result ? result.toLowerCase() : result);
2512
+ }
2513
+ _isWYSIWYG(keybinding) {
2514
+ return this.__isWYSIWYG(keybinding.keyCode);
2515
+ }
2516
+ __isWYSIWYG(keyCode) {
2517
+ if (keyCode === 15
2518
+ || keyCode === 16
2519
+ || keyCode === 17
2520
+ || keyCode === 18 ) {
2521
+ return true;
2522
+ }
2523
+ const ariaLabel = this._mapper.getAriaLabelForKeyCode(keyCode);
2524
+ const userSettingsLabel = this._mapper.getUserSettingsLabelForKeyCode(keyCode);
2525
+ return (ariaLabel === userSettingsLabel);
2526
+ }
2527
+ _getDispatchPart(keybinding) {
2528
+ if (keybinding.isModifierKey()) {
2529
+ return null;
2530
+ }
2531
+ let result = '';
2532
+ if (keybinding.ctrlKey) {
2533
+ result += 'ctrl+';
2534
+ }
2535
+ if (keybinding.shiftKey) {
2536
+ result += 'shift+';
2537
+ }
2538
+ if (keybinding.altKey) {
2539
+ result += 'alt+';
2540
+ }
2541
+ if (keybinding.metaKey) {
2542
+ result += 'meta+';
2543
+ }
2544
+ result += ( (KeyCodeUtils.toString(keybinding.keyCode)));
2545
+ return result;
2546
+ }
2547
+ _getSingleModifierDispatchPart(keybinding) {
2548
+ if (keybinding.keyCode === 5 && !keybinding.shiftKey && !keybinding.altKey && !keybinding.metaKey) {
2549
+ return 'ctrl';
2550
+ }
2551
+ if (keybinding.keyCode === 4 && !keybinding.ctrlKey && !keybinding.altKey && !keybinding.metaKey) {
2552
+ return 'shift';
2553
+ }
2554
+ if (keybinding.keyCode === 6 && !keybinding.ctrlKey && !keybinding.shiftKey && !keybinding.metaKey) {
2555
+ return 'alt';
2556
+ }
2557
+ if (keybinding.keyCode === 57 && !keybinding.ctrlKey && !keybinding.shiftKey && !keybinding.altKey) {
2558
+ return 'meta';
2559
+ }
2560
+ return null;
2561
+ }
2562
+ static getProducedCharCode(kb, mapping) {
2563
+ if (!mapping) {
2564
+ return null;
2565
+ }
2566
+ if (kb.ctrlKey && kb.shiftKey && kb.altKey) {
2567
+ return mapping.withShiftAltGr;
2568
+ }
2569
+ if (kb.ctrlKey && kb.altKey) {
2570
+ return mapping.withAltGr;
2571
+ }
2572
+ if (kb.shiftKey) {
2573
+ return mapping.withShift;
2574
+ }
2575
+ return mapping.value;
2576
+ }
2577
+ static getProducedChar(kb, mapping) {
2578
+ const char = this.getProducedCharCode(kb, mapping);
2579
+ if (char === null || char.length === 0) {
2580
+ return ' --- ';
2581
+ }
2582
+ return ' ' + char + ' ';
2583
+ }
2584
+ }
2585
+ class WindowsKeyboardMapper {
2586
+ constructor(isUSStandard, rawMappings) {
2587
+ this._keyCodeToLabel = [];
2588
+ this.isUSStandard = isUSStandard;
2589
+ this._scanCodeToKeyCode = [];
2590
+ this._keyCodeToLabel = [];
2591
+ this._keyCodeExists = [];
2592
+ this._keyCodeToLabel[0 ] = ( (KeyCodeUtils.toString(0 )));
2593
+ for (let scanCode = 0 ; scanCode < 193 ; scanCode++) {
2594
+ const immutableKeyCode = IMMUTABLE_CODE_TO_KEY_CODE[scanCode];
2595
+ if (immutableKeyCode !== -1 ) {
2596
+ this._scanCodeToKeyCode[scanCode] = immutableKeyCode;
2597
+ this._keyCodeToLabel[immutableKeyCode] = ( (KeyCodeUtils.toString(immutableKeyCode)));
2598
+ this._keyCodeExists[immutableKeyCode] = true;
2599
+ }
2600
+ }
2601
+ const producesLetter = [];
2602
+ let producesLetters = false;
2603
+ this._codeInfo = [];
2604
+ for (const strCode in rawMappings) {
2605
+ if (rawMappings.hasOwnProperty(strCode)) {
2606
+ const scanCode = ScanCodeUtils.toEnum(strCode);
2607
+ if (scanCode === 0 ) {
2608
+ continue;
2609
+ }
2610
+ const rawMapping = rawMappings[strCode];
2611
+ const immutableKeyCode = IMMUTABLE_CODE_TO_KEY_CODE[scanCode];
2612
+ if (immutableKeyCode !== -1 ) {
2613
+ const keyCode = NATIVE_WINDOWS_KEY_CODE_TO_KEY_CODE[rawMapping.vkey] || 0 ;
2614
+ if (keyCode === 0 || immutableKeyCode === keyCode) {
2615
+ continue;
2616
+ }
2617
+ if (scanCode !== 134 ) {
2618
+ continue;
2619
+ }
2620
+ }
2621
+ const value = rawMapping.value;
2622
+ const withShift = rawMapping.withShift;
2623
+ const withAltGr = rawMapping.withAltGr;
2624
+ const withShiftAltGr = rawMapping.withShiftAltGr;
2625
+ const keyCode = NATIVE_WINDOWS_KEY_CODE_TO_KEY_CODE[rawMapping.vkey] || 0 ;
2626
+ const mapping = {
2627
+ scanCode: scanCode,
2628
+ keyCode: keyCode,
2629
+ value: value,
2630
+ withShift: withShift,
2631
+ withAltGr: withAltGr,
2632
+ withShiftAltGr: withShiftAltGr,
2633
+ };
2634
+ this._codeInfo[scanCode] = mapping;
2635
+ this._scanCodeToKeyCode[scanCode] = keyCode;
2636
+ if (keyCode === 0 ) {
2637
+ continue;
2638
+ }
2639
+ this._keyCodeExists[keyCode] = true;
2640
+ if (value.length === 0) {
2641
+ this._keyCodeToLabel[keyCode] = null;
2642
+ }
2643
+ else if (value.length > 1) {
2644
+ this._keyCodeToLabel[keyCode] = value;
2645
+ }
2646
+ else {
2647
+ const charCode = value.charCodeAt(0);
2648
+ if (charCode >= 97 && charCode <= 122 ) {
2649
+ const upperCaseValue = 65 + ((charCode - 97) );
2650
+ producesLetter[upperCaseValue] = true;
2651
+ producesLetters = true;
2652
+ this._keyCodeToLabel[keyCode] = String.fromCharCode(65 + ((charCode - 97) ));
2653
+ }
2654
+ else if (charCode >= 65 && charCode <= 90 ) {
2655
+ producesLetter[charCode] = true;
2656
+ producesLetters = true;
2657
+ this._keyCodeToLabel[keyCode] = value;
2658
+ }
2659
+ else {
2660
+ this._keyCodeToLabel[keyCode] = value;
2661
+ }
2662
+ }
2663
+ }
2664
+ }
2665
+ const _registerLetterIfMissing = (charCode, keyCode) => {
2666
+ if (!producesLetter[charCode]) {
2667
+ this._keyCodeToLabel[keyCode] = String.fromCharCode(charCode);
2668
+ }
2669
+ };
2670
+ _registerLetterIfMissing(65 , 31 );
2671
+ _registerLetterIfMissing(66 , 32 );
2672
+ _registerLetterIfMissing(67 , 33 );
2673
+ _registerLetterIfMissing(68 , 34 );
2674
+ _registerLetterIfMissing(69 , 35 );
2675
+ _registerLetterIfMissing(70 , 36 );
2676
+ _registerLetterIfMissing(71 , 37 );
2677
+ _registerLetterIfMissing(72 , 38 );
2678
+ _registerLetterIfMissing(73 , 39 );
2679
+ _registerLetterIfMissing(74 , 40 );
2680
+ _registerLetterIfMissing(75 , 41 );
2681
+ _registerLetterIfMissing(76 , 42 );
2682
+ _registerLetterIfMissing(77 , 43 );
2683
+ _registerLetterIfMissing(78 , 44 );
2684
+ _registerLetterIfMissing(79 , 45 );
2685
+ _registerLetterIfMissing(80 , 46 );
2686
+ _registerLetterIfMissing(81 , 47 );
2687
+ _registerLetterIfMissing(82 , 48 );
2688
+ _registerLetterIfMissing(83 , 49 );
2689
+ _registerLetterIfMissing(84 , 50 );
2690
+ _registerLetterIfMissing(85 , 51 );
2691
+ _registerLetterIfMissing(86 , 52 );
2692
+ _registerLetterIfMissing(87 , 53 );
2693
+ _registerLetterIfMissing(88 , 54 );
2694
+ _registerLetterIfMissing(89 , 55 );
2695
+ _registerLetterIfMissing(90 , 56 );
2696
+ if (!producesLetters) {
2697
+ const _registerLabel = (keyCode, charCode) => {
2698
+ this._keyCodeToLabel[keyCode] = String.fromCharCode(charCode);
2699
+ };
2700
+ _registerLabel(80 , 59 );
2701
+ _registerLabel(81 , 61 );
2702
+ _registerLabel(82 , 44 );
2703
+ _registerLabel(83 , 45 );
2704
+ _registerLabel(84 , 46 );
2705
+ _registerLabel(85 , 47 );
2706
+ _registerLabel(86 , 96 );
2707
+ _registerLabel(87 , 91 );
2708
+ _registerLabel(88 , 92 );
2709
+ _registerLabel(89 , 93 );
2710
+ _registerLabel(90 , 39 );
2711
+ }
2712
+ }
2713
+ dumpDebugInfo() {
2714
+ const result = [];
2715
+ const immutableSamples = [
2716
+ 88 ,
2717
+ 104
2718
+ ];
2719
+ let cnt = 0;
2720
+ result.push(`-----------------------------------------------------------------------------------------------------------------------------------------`);
2721
+ for (let scanCode = 0 ; scanCode < 193 ; scanCode++) {
2722
+ if (IMMUTABLE_CODE_TO_KEY_CODE[scanCode] !== -1 ) {
2723
+ if (immutableSamples.indexOf(scanCode) === -1) {
2724
+ continue;
2725
+ }
2726
+ }
2727
+ if (cnt % 6 === 0) {
2728
+ result.push(`| HW Code combination | Key | KeyCode combination | UI label | User settings | WYSIWYG |`);
2729
+ result.push(`-----------------------------------------------------------------------------------------------------------------------------------------`);
2730
+ }
2731
+ cnt++;
2732
+ const mapping = this._codeInfo[scanCode];
2733
+ const strCode = ( (ScanCodeUtils.toString(scanCode)));
2734
+ const mods = [0b000, 0b010, 0b101, 0b111];
2735
+ for (const mod of mods) {
2736
+ const ctrlKey = (mod & 0b001) ? true : false;
2737
+ const shiftKey = (mod & 0b010) ? true : false;
2738
+ const altKey = (mod & 0b100) ? true : false;
2739
+ const scanCodeBinding = ( (new ScanCodeBinding(ctrlKey, shiftKey, altKey, false, scanCode)));
2740
+ const kb = this._resolveSimpleUserBinding(scanCodeBinding);
2741
+ const strKeyCode = (kb ? ( (KeyCodeUtils.toString(kb.keyCode))) : null);
2742
+ const resolvedKb = (kb ? ( (new WindowsNativeResolvedKeybinding(this, [kb]))) : null);
2743
+ const outScanCode = `${ctrlKey ? 'Ctrl+' : ''}${shiftKey ? 'Shift+' : ''}${altKey ? 'Alt+' : ''}${strCode}`;
2744
+ const ariaLabel = (resolvedKb ? resolvedKb.getAriaLabel() : null);
2745
+ const outUILabel = (ariaLabel ? ariaLabel.replace(/Control\+/, 'Ctrl+') : null);
2746
+ const outUserSettings = (resolvedKb ? resolvedKb.getUserSettingsLabel() : null);
2747
+ const outKey = WindowsNativeResolvedKeybinding.getProducedChar(scanCodeBinding, mapping);
2748
+ const outKb = (strKeyCode ? `${ctrlKey ? 'Ctrl+' : ''}${shiftKey ? 'Shift+' : ''}${altKey ? 'Alt+' : ''}${strKeyCode}` : null);
2749
+ const isWYSIWYG = (resolvedKb ? resolvedKb.isWYSIWYG() : false);
2750
+ const outWYSIWYG = (isWYSIWYG ? ' ' : ' NO ');
2751
+ result.push(`| ${this._leftPad(outScanCode, 30)} | ${outKey} | ${this._leftPad(outKb, 25)} | ${this._leftPad(outUILabel, 25)} | ${this._leftPad(outUserSettings, 25)} | ${outWYSIWYG} |`);
2752
+ }
2753
+ result.push(`-----------------------------------------------------------------------------------------------------------------------------------------`);
2754
+ }
2755
+ return result.join('\n');
2756
+ }
2757
+ _leftPad(str, cnt) {
2758
+ if (str === null) {
2759
+ str = 'null';
2760
+ }
2761
+ while (str.length < cnt) {
2762
+ str = ' ' + str;
2763
+ }
2764
+ return str;
2765
+ }
2766
+ getUILabelForKeyCode(keyCode) {
2767
+ return this._getLabelForKeyCode(keyCode);
2768
+ }
2769
+ getAriaLabelForKeyCode(keyCode) {
2770
+ return this._getLabelForKeyCode(keyCode);
2771
+ }
2772
+ getUserSettingsLabelForKeyCode(keyCode) {
2773
+ if (this.isUSStandard) {
2774
+ return KeyCodeUtils.toUserSettingsUS(keyCode);
2775
+ }
2776
+ return KeyCodeUtils.toUserSettingsGeneral(keyCode);
2777
+ }
2778
+ getElectronAcceleratorForKeyBinding(keybinding) {
2779
+ return KeyCodeUtils.toElectronAccelerator(keybinding.keyCode);
2780
+ }
2781
+ _getLabelForKeyCode(keyCode) {
2782
+ return this._keyCodeToLabel[keyCode] || ( (KeyCodeUtils.toString(0 )));
2783
+ }
2784
+ resolveKeybinding(keybinding) {
2785
+ const parts = keybinding.parts;
2786
+ for (let i = 0, len = parts.length; i < len; i++) {
2787
+ const part = parts[i];
2788
+ if (!this._keyCodeExists[part.keyCode]) {
2789
+ return [];
2790
+ }
2791
+ }
2792
+ return [( (new WindowsNativeResolvedKeybinding(this, parts)))];
2793
+ }
2794
+ resolveKeyboardEvent(keyboardEvent) {
2795
+ const keybinding = ( (new SimpleKeybinding(
2796
+ keyboardEvent.ctrlKey,
2797
+ keyboardEvent.shiftKey,
2798
+ keyboardEvent.altKey,
2799
+ keyboardEvent.metaKey,
2800
+ keyboardEvent.keyCode
2801
+ )));
2802
+ return (
2803
+ (new WindowsNativeResolvedKeybinding(this, [keybinding]))
2804
+ );
2805
+ }
2806
+ _resolveSimpleUserBinding(binding) {
2807
+ if (!binding) {
2808
+ return null;
2809
+ }
2810
+ if (binding instanceof SimpleKeybinding) {
2811
+ if (!this._keyCodeExists[binding.keyCode]) {
2812
+ return null;
2813
+ }
2814
+ return binding;
2815
+ }
2816
+ const keyCode = this._scanCodeToKeyCode[binding.scanCode] || 0 ;
2817
+ if (keyCode === 0 || !this._keyCodeExists[keyCode]) {
2818
+ return null;
2819
+ }
2820
+ return (
2821
+ (new SimpleKeybinding(
2822
+ binding.ctrlKey,
2823
+ binding.shiftKey,
2824
+ binding.altKey,
2825
+ binding.metaKey,
2826
+ keyCode
2827
+ ))
2828
+ );
2829
+ }
2830
+ resolveUserBinding(input) {
2831
+ const parts = removeElementsAfterNulls(input.map(keybinding => this._resolveSimpleUserBinding(keybinding)));
2832
+ if (parts.length > 0) {
2833
+ return [( (new WindowsNativeResolvedKeybinding(this, parts)))];
2834
+ }
2835
+ return [];
2836
+ }
2837
+ }
2195
2838
  let CommandsQuickAccessProvider = class CommandsQuickAccessProvider extends AbstractEditorCommandsQuickAccessProvider {
2196
2839
  constructor(editorService, menuService, extensionService, instantiationService, keybindingService, commandService, telemetryService, dialogService, configurationService, editorGroupService, preferencesService) {
2197
2840
  super({
@@ -2287,6 +2930,1500 @@ CommandsQuickAccessProvider = ( (__decorate([
2287
2930
  ( (__param(9, IEditorGroupsService))),
2288
2931
  ( (__param(10, IPreferencesService)))
2289
2932
  ], CommandsQuickAccessProvider)));
2933
+ function deserializeMapping(serializedMapping) {
2934
+ const mapping = serializedMapping;
2935
+ const ret = {};
2936
+ for (const key in mapping) {
2937
+ const result = mapping[key];
2938
+ if (result.length) {
2939
+ const value = result[0];
2940
+ const withShift = result[1];
2941
+ const withAltGr = result[2];
2942
+ const withShiftAltGr = result[3];
2943
+ const mask = Number(result[4]);
2944
+ const vkey = result.length === 6 ? result[5] : undefined;
2945
+ ret[key] = {
2946
+ 'value': value,
2947
+ 'vkey': vkey,
2948
+ 'withShift': withShift,
2949
+ 'withAltGr': withAltGr,
2950
+ 'withShiftAltGr': withShiftAltGr,
2951
+ 'valueIsDeadKey': (mask & 1) > 0,
2952
+ 'withShiftIsDeadKey': (mask & 2) > 0,
2953
+ 'withAltGrIsDeadKey': (mask & 4) > 0,
2954
+ 'withShiftAltGrIsDeadKey': (mask & 8) > 0
2955
+ };
2956
+ }
2957
+ else {
2958
+ ret[key] = {
2959
+ 'value': '',
2960
+ 'valueIsDeadKey': false,
2961
+ 'withShift': '',
2962
+ 'withShiftIsDeadKey': false,
2963
+ 'withAltGr': '',
2964
+ 'withAltGrIsDeadKey': false,
2965
+ 'withShiftAltGr': '',
2966
+ 'withShiftAltGrIsDeadKey': false
2967
+ };
2968
+ }
2969
+ }
2970
+ return ret;
2971
+ }
2972
+ class KeymapInfo {
2973
+ constructor(layout, secondaryLayouts, keyboardMapping, isUserKeyboardLayout) {
2974
+ this.layout = layout;
2975
+ this.secondaryLayouts = secondaryLayouts;
2976
+ this.mapping = deserializeMapping(keyboardMapping);
2977
+ this.isUserKeyboardLayout = !!isUserKeyboardLayout;
2978
+ this.layout.isUserKeyboardLayout = !!isUserKeyboardLayout;
2979
+ }
2980
+ static createKeyboardLayoutFromDebugInfo(layout, value, isUserKeyboardLayout) {
2981
+ const keyboardLayoutInfo = ( (new KeymapInfo(layout, [], {}, true)));
2982
+ keyboardLayoutInfo.mapping = value;
2983
+ return keyboardLayoutInfo;
2984
+ }
2985
+ update(other) {
2986
+ this.layout = other.layout;
2987
+ this.secondaryLayouts = other.secondaryLayouts;
2988
+ this.mapping = other.mapping;
2989
+ this.isUserKeyboardLayout = other.isUserKeyboardLayout;
2990
+ this.layout.isUserKeyboardLayout = other.isUserKeyboardLayout;
2991
+ }
2992
+ getScore(other) {
2993
+ let score = 0;
2994
+ for (const key in other) {
2995
+ if (isWindows && (key === 'Backslash' || key === 'KeyQ')) {
2996
+ continue;
2997
+ }
2998
+ if (isLinux && (key === 'Backspace' || key === 'Escape')) {
2999
+ continue;
3000
+ }
3001
+ const currentMapping = this.mapping[key];
3002
+ if (currentMapping === undefined) {
3003
+ score -= 1;
3004
+ }
3005
+ const otherMapping = other[key];
3006
+ if (currentMapping && otherMapping && currentMapping.value !== otherMapping.value) {
3007
+ score -= 1;
3008
+ }
3009
+ }
3010
+ return score;
3011
+ }
3012
+ equal(other) {
3013
+ if (this.isUserKeyboardLayout !== other.isUserKeyboardLayout) {
3014
+ return false;
3015
+ }
3016
+ if (getKeyboardLayoutId(this.layout) !== getKeyboardLayoutId(other.layout)) {
3017
+ return false;
3018
+ }
3019
+ return this.fuzzyEqual(other.mapping);
3020
+ }
3021
+ fuzzyEqual(other) {
3022
+ for (const key in other) {
3023
+ if (isWindows && (key === 'Backslash' || key === 'KeyQ')) {
3024
+ continue;
3025
+ }
3026
+ if (this.mapping[key] === undefined) {
3027
+ return false;
3028
+ }
3029
+ const currentMapping = this.mapping[key];
3030
+ const otherMapping = other[key];
3031
+ if (currentMapping.value !== otherMapping.value) {
3032
+ return false;
3033
+ }
3034
+ }
3035
+ return true;
3036
+ }
3037
+ }
3038
+ class CachedKeyboardMapper {
3039
+ constructor(actual) {
3040
+ this._actual = actual;
3041
+ this._cache = ( (new Map()));
3042
+ }
3043
+ dumpDebugInfo() {
3044
+ return this._actual.dumpDebugInfo();
3045
+ }
3046
+ resolveKeybinding(keybinding) {
3047
+ const hashCode = keybinding.getHashCode();
3048
+ const resolved = this._cache.get(hashCode);
3049
+ if (!resolved) {
3050
+ const r = this._actual.resolveKeybinding(keybinding);
3051
+ this._cache.set(hashCode, r);
3052
+ return r;
3053
+ }
3054
+ return resolved;
3055
+ }
3056
+ resolveKeyboardEvent(keyboardEvent) {
3057
+ return this._actual.resolveKeyboardEvent(keyboardEvent);
3058
+ }
3059
+ resolveUserBinding(parts) {
3060
+ return this._actual.resolveUserBinding(parts);
3061
+ }
3062
+ }
3063
+ const CHAR_CODE_TO_KEY_CODE = [];
3064
+ class NativeResolvedKeybinding extends BaseResolvedKeybinding {
3065
+ constructor(mapper, os, parts) {
3066
+ super(os, parts);
3067
+ this._mapper = mapper;
3068
+ }
3069
+ _getLabel(keybinding) {
3070
+ return this._mapper.getUILabelForScanCodeBinding(keybinding);
3071
+ }
3072
+ _getAriaLabel(keybinding) {
3073
+ return this._mapper.getAriaLabelForScanCodeBinding(keybinding);
3074
+ }
3075
+ _getElectronAccelerator(keybinding) {
3076
+ return this._mapper.getElectronAcceleratorLabelForScanCodeBinding(keybinding);
3077
+ }
3078
+ _getUserSettingsLabel(keybinding) {
3079
+ return this._mapper.getUserSettingsLabelForScanCodeBinding(keybinding);
3080
+ }
3081
+ _isWYSIWYG(binding) {
3082
+ if (!binding) {
3083
+ return true;
3084
+ }
3085
+ if (IMMUTABLE_CODE_TO_KEY_CODE[binding.scanCode] !== -1 ) {
3086
+ return true;
3087
+ }
3088
+ const a = this._mapper.getAriaLabelForScanCodeBinding(binding);
3089
+ const b = this._mapper.getUserSettingsLabelForScanCodeBinding(binding);
3090
+ if (!a && !b) {
3091
+ return true;
3092
+ }
3093
+ if (!a || !b) {
3094
+ return false;
3095
+ }
3096
+ return (a.toLowerCase() === b.toLowerCase());
3097
+ }
3098
+ _getDispatchPart(keybinding) {
3099
+ return this._mapper.getDispatchStrForScanCodeBinding(keybinding);
3100
+ }
3101
+ _getSingleModifierDispatchPart(keybinding) {
3102
+ if (((keybinding.scanCode === 157 || keybinding.scanCode === 161) ) && !keybinding.shiftKey && !keybinding.altKey && !keybinding.metaKey) {
3103
+ return 'ctrl';
3104
+ }
3105
+ if (((keybinding.scanCode === 159 || keybinding.scanCode === 163) ) && !keybinding.ctrlKey && !keybinding.shiftKey && !keybinding.metaKey) {
3106
+ return 'alt';
3107
+ }
3108
+ if (((keybinding.scanCode === 158 || keybinding.scanCode === 162) ) && !keybinding.ctrlKey && !keybinding.altKey && !keybinding.metaKey) {
3109
+ return 'shift';
3110
+ }
3111
+ if (((keybinding.scanCode === 160 || keybinding.scanCode === 164) ) && !keybinding.ctrlKey && !keybinding.shiftKey && !keybinding.altKey) {
3112
+ return 'meta';
3113
+ }
3114
+ return null;
3115
+ }
3116
+ }
3117
+ class ScanCodeCombo {
3118
+ constructor(ctrlKey, shiftKey, altKey, scanCode) {
3119
+ this.ctrlKey = ctrlKey;
3120
+ this.shiftKey = shiftKey;
3121
+ this.altKey = altKey;
3122
+ this.scanCode = scanCode;
3123
+ }
3124
+ toString() {
3125
+ return `${this.ctrlKey ? 'Ctrl+' : ''}${this.shiftKey ? 'Shift+' : ''}${this.altKey ? 'Alt+' : ''}${( ( ScanCodeUtils.toString(this.scanCode)))}`;
3126
+ }
3127
+ equals(other) {
3128
+ return (this.ctrlKey === other.ctrlKey
3129
+ && this.shiftKey === other.shiftKey
3130
+ && this.altKey === other.altKey
3131
+ && this.scanCode === other.scanCode);
3132
+ }
3133
+ getProducedCharCode(mapping) {
3134
+ if (!mapping) {
3135
+ return '';
3136
+ }
3137
+ if (this.ctrlKey && this.shiftKey && this.altKey) {
3138
+ return mapping.withShiftAltGr;
3139
+ }
3140
+ if (this.ctrlKey && this.altKey) {
3141
+ return mapping.withAltGr;
3142
+ }
3143
+ if (this.shiftKey) {
3144
+ return mapping.withShift;
3145
+ }
3146
+ return mapping.value;
3147
+ }
3148
+ getProducedChar(mapping) {
3149
+ const charCode = MacLinuxKeyboardMapper.getCharCode(this.getProducedCharCode(mapping));
3150
+ if (charCode === 0) {
3151
+ return ' --- ';
3152
+ }
3153
+ if (charCode >= 768 && charCode <= 879 ) {
3154
+ return 'U+' + ( (charCode.toString(16)));
3155
+ }
3156
+ return ' ' + String.fromCharCode(charCode) + ' ';
3157
+ }
3158
+ }
3159
+ class KeyCodeCombo {
3160
+ constructor(ctrlKey, shiftKey, altKey, keyCode) {
3161
+ this.ctrlKey = ctrlKey;
3162
+ this.shiftKey = shiftKey;
3163
+ this.altKey = altKey;
3164
+ this.keyCode = keyCode;
3165
+ }
3166
+ toString() {
3167
+ return `${this.ctrlKey ? 'Ctrl+' : ''}${this.shiftKey ? 'Shift+' : ''}${this.altKey ? 'Alt+' : ''}${( ( KeyCodeUtils.toString(this.keyCode)))}`;
3168
+ }
3169
+ }
3170
+ class ScanCodeKeyCodeMapper {
3171
+ constructor() {
3172
+ this._scanCodeToKeyCode = [];
3173
+ this._keyCodeToScanCode = [];
3174
+ this._scanCodeToKeyCode = [];
3175
+ this._keyCodeToScanCode = [];
3176
+ }
3177
+ registrationComplete() {
3178
+ this._moveToEnd(56 );
3179
+ this._moveToEnd(106 );
3180
+ }
3181
+ _moveToEnd(scanCode) {
3182
+ for (let mod = 0; mod < 8; mod++) {
3183
+ const encodedKeyCodeCombos = this._scanCodeToKeyCode[(scanCode << 3) + mod];
3184
+ if (!encodedKeyCodeCombos) {
3185
+ continue;
3186
+ }
3187
+ for (let i = 0, len = encodedKeyCodeCombos.length; i < len; i++) {
3188
+ const encodedScanCodeCombos = this._keyCodeToScanCode[encodedKeyCodeCombos[i]];
3189
+ if (encodedScanCodeCombos.length === 1) {
3190
+ continue;
3191
+ }
3192
+ for (let j = 0, len = encodedScanCodeCombos.length; j < len; j++) {
3193
+ const entry = encodedScanCodeCombos[j];
3194
+ const entryScanCode = (entry >>> 3);
3195
+ if (entryScanCode === scanCode) {
3196
+ for (let k = j + 1; k < len; k++) {
3197
+ encodedScanCodeCombos[k - 1] = encodedScanCodeCombos[k];
3198
+ }
3199
+ encodedScanCodeCombos[len - 1] = entry;
3200
+ }
3201
+ }
3202
+ }
3203
+ }
3204
+ }
3205
+ registerIfUnknown(scanCodeCombo, keyCodeCombo) {
3206
+ if (keyCodeCombo.keyCode === 0 ) {
3207
+ return;
3208
+ }
3209
+ const scanCodeComboEncoded = this._encodeScanCodeCombo(scanCodeCombo);
3210
+ const keyCodeComboEncoded = this._encodeKeyCodeCombo(keyCodeCombo);
3211
+ const keyCodeIsDigit = ((keyCodeCombo.keyCode >= 21 && keyCodeCombo.keyCode <= 30) );
3212
+ const keyCodeIsLetter = ((keyCodeCombo.keyCode >= 31 && keyCodeCombo.keyCode <= 56) );
3213
+ const existingKeyCodeCombos = this._scanCodeToKeyCode[scanCodeComboEncoded];
3214
+ if (keyCodeIsDigit || keyCodeIsLetter) {
3215
+ if (existingKeyCodeCombos) {
3216
+ for (let i = 0, len = existingKeyCodeCombos.length; i < len; i++) {
3217
+ if (existingKeyCodeCombos[i] === keyCodeComboEncoded) {
3218
+ return;
3219
+ }
3220
+ }
3221
+ }
3222
+ }
3223
+ else {
3224
+ if (existingKeyCodeCombos && existingKeyCodeCombos.length !== 0) {
3225
+ return;
3226
+ }
3227
+ }
3228
+ this._scanCodeToKeyCode[scanCodeComboEncoded] = this._scanCodeToKeyCode[scanCodeComboEncoded] || [];
3229
+ this._scanCodeToKeyCode[scanCodeComboEncoded].unshift(keyCodeComboEncoded);
3230
+ this._keyCodeToScanCode[keyCodeComboEncoded] = this._keyCodeToScanCode[keyCodeComboEncoded] || [];
3231
+ this._keyCodeToScanCode[keyCodeComboEncoded].unshift(scanCodeComboEncoded);
3232
+ }
3233
+ lookupKeyCodeCombo(keyCodeCombo) {
3234
+ const keyCodeComboEncoded = this._encodeKeyCodeCombo(keyCodeCombo);
3235
+ const scanCodeCombosEncoded = this._keyCodeToScanCode[keyCodeComboEncoded];
3236
+ if (!scanCodeCombosEncoded || scanCodeCombosEncoded.length === 0) {
3237
+ return [];
3238
+ }
3239
+ const result = [];
3240
+ for (let i = 0, len = scanCodeCombosEncoded.length; i < len; i++) {
3241
+ const scanCodeComboEncoded = scanCodeCombosEncoded[i];
3242
+ const ctrlKey = (scanCodeComboEncoded & 0b001) ? true : false;
3243
+ const shiftKey = (scanCodeComboEncoded & 0b010) ? true : false;
3244
+ const altKey = (scanCodeComboEncoded & 0b100) ? true : false;
3245
+ const scanCode = (scanCodeComboEncoded >>> 3);
3246
+ result[i] = ( (new ScanCodeCombo(ctrlKey, shiftKey, altKey, scanCode)));
3247
+ }
3248
+ return result;
3249
+ }
3250
+ lookupScanCodeCombo(scanCodeCombo) {
3251
+ const scanCodeComboEncoded = this._encodeScanCodeCombo(scanCodeCombo);
3252
+ const keyCodeCombosEncoded = this._scanCodeToKeyCode[scanCodeComboEncoded];
3253
+ if (!keyCodeCombosEncoded || keyCodeCombosEncoded.length === 0) {
3254
+ return [];
3255
+ }
3256
+ const result = [];
3257
+ for (let i = 0, len = keyCodeCombosEncoded.length; i < len; i++) {
3258
+ const keyCodeComboEncoded = keyCodeCombosEncoded[i];
3259
+ const ctrlKey = (keyCodeComboEncoded & 0b001) ? true : false;
3260
+ const shiftKey = (keyCodeComboEncoded & 0b010) ? true : false;
3261
+ const altKey = (keyCodeComboEncoded & 0b100) ? true : false;
3262
+ const keyCode = (keyCodeComboEncoded >>> 3);
3263
+ result[i] = ( (new KeyCodeCombo(ctrlKey, shiftKey, altKey, keyCode)));
3264
+ }
3265
+ return result;
3266
+ }
3267
+ guessStableKeyCode(scanCode) {
3268
+ if (scanCode >= 36 && scanCode <= 45 ) {
3269
+ switch (scanCode) {
3270
+ case 36 : return 22 ;
3271
+ case 37 : return 23 ;
3272
+ case 38 : return 24 ;
3273
+ case 39 : return 25 ;
3274
+ case 40 : return 26 ;
3275
+ case 41 : return 27 ;
3276
+ case 42 : return 28 ;
3277
+ case 43 : return 29 ;
3278
+ case 44 : return 30 ;
3279
+ case 45 : return 21 ;
3280
+ }
3281
+ }
3282
+ const keyCodeCombos1 = this.lookupScanCodeCombo(( (new ScanCodeCombo(false, false, false, scanCode))));
3283
+ const keyCodeCombos2 = this.lookupScanCodeCombo(( (new ScanCodeCombo(false, true, false, scanCode))));
3284
+ if (keyCodeCombos1.length === 1 && keyCodeCombos2.length === 1) {
3285
+ const shiftKey1 = keyCodeCombos1[0].shiftKey;
3286
+ const keyCode1 = keyCodeCombos1[0].keyCode;
3287
+ const shiftKey2 = keyCodeCombos2[0].shiftKey;
3288
+ const keyCode2 = keyCodeCombos2[0].keyCode;
3289
+ if (keyCode1 === keyCode2 && shiftKey1 !== shiftKey2) {
3290
+ return keyCode1;
3291
+ }
3292
+ }
3293
+ return -1 ;
3294
+ }
3295
+ _encodeScanCodeCombo(scanCodeCombo) {
3296
+ return this._encode(scanCodeCombo.ctrlKey, scanCodeCombo.shiftKey, scanCodeCombo.altKey, scanCodeCombo.scanCode);
3297
+ }
3298
+ _encodeKeyCodeCombo(keyCodeCombo) {
3299
+ return this._encode(keyCodeCombo.ctrlKey, keyCodeCombo.shiftKey, keyCodeCombo.altKey, keyCodeCombo.keyCode);
3300
+ }
3301
+ _encode(ctrlKey, shiftKey, altKey, principal) {
3302
+ return (((ctrlKey ? 1 : 0) << 0)
3303
+ | ((shiftKey ? 1 : 0) << 1)
3304
+ | ((altKey ? 1 : 0) << 2)
3305
+ | principal << 3) >>> 0;
3306
+ }
3307
+ }
3308
+ class MacLinuxKeyboardMapper {
3309
+ constructor(isUSStandard, rawMappings, OS) {
3310
+ this._scanCodeToLabel = [];
3311
+ this._scanCodeToDispatch = [];
3312
+ this._isUSStandard = isUSStandard;
3313
+ this._OS = OS;
3314
+ this._codeInfo = [];
3315
+ this._scanCodeKeyCodeMapper = ( (new ScanCodeKeyCodeMapper()));
3316
+ this._scanCodeToLabel = [];
3317
+ this._scanCodeToDispatch = [];
3318
+ const _registerIfUnknown = (hwCtrlKey, hwShiftKey, hwAltKey, scanCode, kbCtrlKey, kbShiftKey, kbAltKey, keyCode) => {
3319
+ this._scanCodeKeyCodeMapper.registerIfUnknown(( (new ScanCodeCombo(
3320
+ hwCtrlKey ? true : false,
3321
+ hwShiftKey ? true : false,
3322
+ hwAltKey ? true : false,
3323
+ scanCode
3324
+ ))), ( (new KeyCodeCombo(
3325
+ kbCtrlKey ? true : false,
3326
+ kbShiftKey ? true : false,
3327
+ kbAltKey ? true : false,
3328
+ keyCode
3329
+ ))));
3330
+ };
3331
+ const _registerAllCombos = (_ctrlKey, _shiftKey, _altKey, scanCode, keyCode) => {
3332
+ for (let ctrlKey = _ctrlKey; ctrlKey <= 1; ctrlKey++) {
3333
+ for (let shiftKey = _shiftKey; shiftKey <= 1; shiftKey++) {
3334
+ for (let altKey = _altKey; altKey <= 1; altKey++) {
3335
+ _registerIfUnknown(ctrlKey, shiftKey, altKey, scanCode, ctrlKey, shiftKey, altKey, keyCode);
3336
+ }
3337
+ }
3338
+ }
3339
+ };
3340
+ for (let scanCode = 0 ; scanCode < 193 ; scanCode++) {
3341
+ this._scanCodeToLabel[scanCode] = null;
3342
+ }
3343
+ for (let scanCode = 0 ; scanCode < 193 ; scanCode++) {
3344
+ this._scanCodeToDispatch[scanCode] = null;
3345
+ }
3346
+ for (let scanCode = 0 ; scanCode < 193 ; scanCode++) {
3347
+ const keyCode = IMMUTABLE_CODE_TO_KEY_CODE[scanCode];
3348
+ if (keyCode !== -1 ) {
3349
+ _registerAllCombos(0, 0, 0, scanCode, keyCode);
3350
+ this._scanCodeToLabel[scanCode] = ( (KeyCodeUtils.toString(keyCode)));
3351
+ if (keyCode === 0 || keyCode === 5 || keyCode === 57 || keyCode === 6 || keyCode === 4 ) {
3352
+ this._scanCodeToDispatch[scanCode] = null;
3353
+ }
3354
+ else {
3355
+ this._scanCodeToDispatch[scanCode] = `[${( ( ScanCodeUtils.toString(scanCode)))}]`;
3356
+ }
3357
+ }
3358
+ }
3359
+ const missingLatinLettersOverride = {};
3360
+ {
3361
+ const producesLatinLetter = [];
3362
+ for (const strScanCode in rawMappings) {
3363
+ if (rawMappings.hasOwnProperty(strScanCode)) {
3364
+ const scanCode = ScanCodeUtils.toEnum(strScanCode);
3365
+ if (scanCode === 0 ) {
3366
+ continue;
3367
+ }
3368
+ if (IMMUTABLE_CODE_TO_KEY_CODE[scanCode] !== -1 ) {
3369
+ continue;
3370
+ }
3371
+ const rawMapping = rawMappings[strScanCode];
3372
+ const value = MacLinuxKeyboardMapper.getCharCode(rawMapping.value);
3373
+ if (value >= 97 && value <= 122 ) {
3374
+ const upperCaseValue = 65 + ((value - 97) );
3375
+ producesLatinLetter[upperCaseValue] = true;
3376
+ }
3377
+ }
3378
+ }
3379
+ const _registerLetterIfMissing = (charCode, scanCode, value, withShift) => {
3380
+ if (!producesLatinLetter[charCode]) {
3381
+ missingLatinLettersOverride[( (ScanCodeUtils.toString(scanCode)))] = {
3382
+ value: value,
3383
+ withShift: withShift,
3384
+ withAltGr: '',
3385
+ withShiftAltGr: ''
3386
+ };
3387
+ }
3388
+ };
3389
+ _registerLetterIfMissing(65 , 10 , 'a', 'A');
3390
+ _registerLetterIfMissing(66 , 11 , 'b', 'B');
3391
+ _registerLetterIfMissing(67 , 12 , 'c', 'C');
3392
+ _registerLetterIfMissing(68 , 13 , 'd', 'D');
3393
+ _registerLetterIfMissing(69 , 14 , 'e', 'E');
3394
+ _registerLetterIfMissing(70 , 15 , 'f', 'F');
3395
+ _registerLetterIfMissing(71 , 16 , 'g', 'G');
3396
+ _registerLetterIfMissing(72 , 17 , 'h', 'H');
3397
+ _registerLetterIfMissing(73 , 18 , 'i', 'I');
3398
+ _registerLetterIfMissing(74 , 19 , 'j', 'J');
3399
+ _registerLetterIfMissing(75 , 20 , 'k', 'K');
3400
+ _registerLetterIfMissing(76 , 21 , 'l', 'L');
3401
+ _registerLetterIfMissing(77 , 22 , 'm', 'M');
3402
+ _registerLetterIfMissing(78 , 23 , 'n', 'N');
3403
+ _registerLetterIfMissing(79 , 24 , 'o', 'O');
3404
+ _registerLetterIfMissing(80 , 25 , 'p', 'P');
3405
+ _registerLetterIfMissing(81 , 26 , 'q', 'Q');
3406
+ _registerLetterIfMissing(82 , 27 , 'r', 'R');
3407
+ _registerLetterIfMissing(83 , 28 , 's', 'S');
3408
+ _registerLetterIfMissing(84 , 29 , 't', 'T');
3409
+ _registerLetterIfMissing(85 , 30 , 'u', 'U');
3410
+ _registerLetterIfMissing(86 , 31 , 'v', 'V');
3411
+ _registerLetterIfMissing(87 , 32 , 'w', 'W');
3412
+ _registerLetterIfMissing(88 , 33 , 'x', 'X');
3413
+ _registerLetterIfMissing(89 , 34 , 'y', 'Y');
3414
+ _registerLetterIfMissing(90 , 35 , 'z', 'Z');
3415
+ }
3416
+ const mappings = [];
3417
+ let mappingsLen = 0;
3418
+ for (const strScanCode in rawMappings) {
3419
+ if (rawMappings.hasOwnProperty(strScanCode)) {
3420
+ const scanCode = ScanCodeUtils.toEnum(strScanCode);
3421
+ if (scanCode === 0 ) {
3422
+ continue;
3423
+ }
3424
+ if (IMMUTABLE_CODE_TO_KEY_CODE[scanCode] !== -1 ) {
3425
+ continue;
3426
+ }
3427
+ this._codeInfo[scanCode] = rawMappings[strScanCode];
3428
+ const rawMapping = missingLatinLettersOverride[strScanCode] || rawMappings[strScanCode];
3429
+ const value = MacLinuxKeyboardMapper.getCharCode(rawMapping.value);
3430
+ const withShift = MacLinuxKeyboardMapper.getCharCode(rawMapping.withShift);
3431
+ const withAltGr = MacLinuxKeyboardMapper.getCharCode(rawMapping.withAltGr);
3432
+ const withShiftAltGr = MacLinuxKeyboardMapper.getCharCode(rawMapping.withShiftAltGr);
3433
+ const mapping = {
3434
+ scanCode: scanCode,
3435
+ value: value,
3436
+ withShift: withShift,
3437
+ withAltGr: withAltGr,
3438
+ withShiftAltGr: withShiftAltGr,
3439
+ };
3440
+ mappings[mappingsLen++] = mapping;
3441
+ this._scanCodeToDispatch[scanCode] = `[${( ( ScanCodeUtils.toString(scanCode)))}]`;
3442
+ if (value >= 97 && value <= 122 ) {
3443
+ const upperCaseValue = 65 + ((value - 97) );
3444
+ this._scanCodeToLabel[scanCode] = String.fromCharCode(upperCaseValue);
3445
+ }
3446
+ else if (value >= 65 && value <= 90 ) {
3447
+ this._scanCodeToLabel[scanCode] = String.fromCharCode(value);
3448
+ }
3449
+ else if (value) {
3450
+ this._scanCodeToLabel[scanCode] = String.fromCharCode(value);
3451
+ }
3452
+ else {
3453
+ this._scanCodeToLabel[scanCode] = null;
3454
+ }
3455
+ }
3456
+ }
3457
+ for (let i = mappings.length - 1; i >= 0; i--) {
3458
+ const mapping = mappings[i];
3459
+ const scanCode = mapping.scanCode;
3460
+ const withShiftAltGr = mapping.withShiftAltGr;
3461
+ if (withShiftAltGr === mapping.withAltGr || withShiftAltGr === mapping.withShift || withShiftAltGr === mapping.value) {
3462
+ continue;
3463
+ }
3464
+ const kb = MacLinuxKeyboardMapper._charCodeToKb(withShiftAltGr);
3465
+ if (!kb) {
3466
+ continue;
3467
+ }
3468
+ const kbShiftKey = kb.shiftKey;
3469
+ const keyCode = kb.keyCode;
3470
+ if (kbShiftKey) {
3471
+ _registerIfUnknown(1, 1, 1, scanCode, 0, 1, 0, keyCode);
3472
+ }
3473
+ else {
3474
+ _registerIfUnknown(1, 1, 1, scanCode, 0, 0, 0, keyCode);
3475
+ }
3476
+ }
3477
+ for (let i = mappings.length - 1; i >= 0; i--) {
3478
+ const mapping = mappings[i];
3479
+ const scanCode = mapping.scanCode;
3480
+ const withAltGr = mapping.withAltGr;
3481
+ if (withAltGr === mapping.withShift || withAltGr === mapping.value) {
3482
+ continue;
3483
+ }
3484
+ const kb = MacLinuxKeyboardMapper._charCodeToKb(withAltGr);
3485
+ if (!kb) {
3486
+ continue;
3487
+ }
3488
+ const kbShiftKey = kb.shiftKey;
3489
+ const keyCode = kb.keyCode;
3490
+ if (kbShiftKey) {
3491
+ _registerIfUnknown(1, 0, 1, scanCode, 0, 1, 0, keyCode);
3492
+ }
3493
+ else {
3494
+ _registerIfUnknown(1, 0, 1, scanCode, 0, 0, 0, keyCode);
3495
+ }
3496
+ }
3497
+ for (let i = mappings.length - 1; i >= 0; i--) {
3498
+ const mapping = mappings[i];
3499
+ const scanCode = mapping.scanCode;
3500
+ const withShift = mapping.withShift;
3501
+ if (withShift === mapping.value) {
3502
+ continue;
3503
+ }
3504
+ const kb = MacLinuxKeyboardMapper._charCodeToKb(withShift);
3505
+ if (!kb) {
3506
+ continue;
3507
+ }
3508
+ const kbShiftKey = kb.shiftKey;
3509
+ const keyCode = kb.keyCode;
3510
+ if (kbShiftKey) {
3511
+ _registerIfUnknown(0, 1, 0, scanCode, 0, 1, 0, keyCode);
3512
+ _registerIfUnknown(0, 1, 1, scanCode, 0, 1, 1, keyCode);
3513
+ _registerIfUnknown(1, 1, 0, scanCode, 1, 1, 0, keyCode);
3514
+ _registerIfUnknown(1, 1, 1, scanCode, 1, 1, 1, keyCode);
3515
+ }
3516
+ else {
3517
+ _registerIfUnknown(0, 1, 0, scanCode, 0, 0, 0, keyCode);
3518
+ _registerIfUnknown(0, 1, 0, scanCode, 0, 1, 0, keyCode);
3519
+ _registerIfUnknown(0, 1, 1, scanCode, 0, 0, 1, keyCode);
3520
+ _registerIfUnknown(0, 1, 1, scanCode, 0, 1, 1, keyCode);
3521
+ _registerIfUnknown(1, 1, 0, scanCode, 1, 0, 0, keyCode);
3522
+ _registerIfUnknown(1, 1, 0, scanCode, 1, 1, 0, keyCode);
3523
+ _registerIfUnknown(1, 1, 1, scanCode, 1, 0, 1, keyCode);
3524
+ _registerIfUnknown(1, 1, 1, scanCode, 1, 1, 1, keyCode);
3525
+ }
3526
+ }
3527
+ for (let i = mappings.length - 1; i >= 0; i--) {
3528
+ const mapping = mappings[i];
3529
+ const scanCode = mapping.scanCode;
3530
+ const kb = MacLinuxKeyboardMapper._charCodeToKb(mapping.value);
3531
+ if (!kb) {
3532
+ continue;
3533
+ }
3534
+ const kbShiftKey = kb.shiftKey;
3535
+ const keyCode = kb.keyCode;
3536
+ if (kbShiftKey) {
3537
+ _registerIfUnknown(0, 0, 0, scanCode, 0, 1, 0, keyCode);
3538
+ _registerIfUnknown(0, 0, 1, scanCode, 0, 1, 1, keyCode);
3539
+ _registerIfUnknown(1, 0, 0, scanCode, 1, 1, 0, keyCode);
3540
+ _registerIfUnknown(1, 0, 1, scanCode, 1, 1, 1, keyCode);
3541
+ }
3542
+ else {
3543
+ _registerIfUnknown(0, 0, 0, scanCode, 0, 0, 0, keyCode);
3544
+ _registerIfUnknown(0, 0, 1, scanCode, 0, 0, 1, keyCode);
3545
+ _registerIfUnknown(0, 1, 0, scanCode, 0, 1, 0, keyCode);
3546
+ _registerIfUnknown(0, 1, 1, scanCode, 0, 1, 1, keyCode);
3547
+ _registerIfUnknown(1, 0, 0, scanCode, 1, 0, 0, keyCode);
3548
+ _registerIfUnknown(1, 0, 1, scanCode, 1, 0, 1, keyCode);
3549
+ _registerIfUnknown(1, 1, 0, scanCode, 1, 1, 0, keyCode);
3550
+ _registerIfUnknown(1, 1, 1, scanCode, 1, 1, 1, keyCode);
3551
+ }
3552
+ }
3553
+ _registerAllCombos(0, 0, 0, 36 , 22 );
3554
+ _registerAllCombos(0, 0, 0, 37 , 23 );
3555
+ _registerAllCombos(0, 0, 0, 38 , 24 );
3556
+ _registerAllCombos(0, 0, 0, 39 , 25 );
3557
+ _registerAllCombos(0, 0, 0, 40 , 26 );
3558
+ _registerAllCombos(0, 0, 0, 41 , 27 );
3559
+ _registerAllCombos(0, 0, 0, 42 , 28 );
3560
+ _registerAllCombos(0, 0, 0, 43 , 29 );
3561
+ _registerAllCombos(0, 0, 0, 44 , 30 );
3562
+ _registerAllCombos(0, 0, 0, 45 , 21 );
3563
+ this._scanCodeKeyCodeMapper.registrationComplete();
3564
+ }
3565
+ dumpDebugInfo() {
3566
+ const result = [];
3567
+ const immutableSamples = [
3568
+ 88 ,
3569
+ 104
3570
+ ];
3571
+ let cnt = 0;
3572
+ result.push(`isUSStandard: ${this._isUSStandard}`);
3573
+ result.push(`----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------`);
3574
+ for (let scanCode = 0 ; scanCode < 193 ; scanCode++) {
3575
+ if (IMMUTABLE_CODE_TO_KEY_CODE[scanCode] !== -1 ) {
3576
+ if (immutableSamples.indexOf(scanCode) === -1) {
3577
+ continue;
3578
+ }
3579
+ }
3580
+ if (cnt % 4 === 0) {
3581
+ result.push(`| HW Code combination | Key | KeyCode combination | Pri | UI label | User settings | Electron accelerator | Dispatching string | WYSIWYG |`);
3582
+ result.push(`----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------`);
3583
+ }
3584
+ cnt++;
3585
+ const mapping = this._codeInfo[scanCode];
3586
+ for (let mod = 0; mod < 8; mod++) {
3587
+ const hwCtrlKey = (mod & 0b001) ? true : false;
3588
+ const hwShiftKey = (mod & 0b010) ? true : false;
3589
+ const hwAltKey = (mod & 0b100) ? true : false;
3590
+ const scanCodeCombo = ( (new ScanCodeCombo(hwCtrlKey, hwShiftKey, hwAltKey, scanCode)));
3591
+ const resolvedKb = this.resolveKeyboardEvent({
3592
+ _standardKeyboardEventBrand: true,
3593
+ ctrlKey: scanCodeCombo.ctrlKey,
3594
+ shiftKey: scanCodeCombo.shiftKey,
3595
+ altKey: scanCodeCombo.altKey,
3596
+ metaKey: false,
3597
+ keyCode: -1 ,
3598
+ code: ( (ScanCodeUtils.toString(scanCode)))
3599
+ });
3600
+ const outScanCodeCombo = ( (scanCodeCombo.toString()));
3601
+ const outKey = scanCodeCombo.getProducedChar(mapping);
3602
+ const ariaLabel = resolvedKb.getAriaLabel();
3603
+ const outUILabel = (ariaLabel ? ariaLabel.replace(/Control\+/, 'Ctrl+') : null);
3604
+ const outUserSettings = resolvedKb.getUserSettingsLabel();
3605
+ const outElectronAccelerator = resolvedKb.getElectronAccelerator();
3606
+ const outDispatchStr = resolvedKb.getDispatchParts()[0];
3607
+ const isWYSIWYG = (resolvedKb ? resolvedKb.isWYSIWYG() : false);
3608
+ const outWYSIWYG = (isWYSIWYG ? ' ' : ' NO ');
3609
+ const kbCombos = this._scanCodeKeyCodeMapper.lookupScanCodeCombo(scanCodeCombo);
3610
+ if (kbCombos.length === 0) {
3611
+ 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} |`);
3612
+ }
3613
+ else {
3614
+ for (let i = 0, len = kbCombos.length; i < len; i++) {
3615
+ const kbCombo = kbCombos[i];
3616
+ let colPriority;
3617
+ const scanCodeCombos = this._scanCodeKeyCodeMapper.lookupKeyCodeCombo(kbCombo);
3618
+ if (scanCodeCombos.length === 1) {
3619
+ colPriority = '';
3620
+ }
3621
+ else {
3622
+ let priority = -1;
3623
+ for (let j = 0; j < scanCodeCombos.length; j++) {
3624
+ if (scanCodeCombos[j].equals(scanCodeCombo)) {
3625
+ priority = j + 1;
3626
+ break;
3627
+ }
3628
+ }
3629
+ colPriority = String(priority);
3630
+ }
3631
+ const outKeybinding = ( (kbCombo.toString()));
3632
+ if (i === 0) {
3633
+ 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} |`);
3634
+ }
3635
+ else {
3636
+ 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)} | |`);
3637
+ }
3638
+ }
3639
+ }
3640
+ }
3641
+ result.push(`----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------`);
3642
+ }
3643
+ return result.join('\n');
3644
+ }
3645
+ _leftPad(str, cnt) {
3646
+ if (str === null) {
3647
+ str = 'null';
3648
+ }
3649
+ while (str.length < cnt) {
3650
+ str = ' ' + str;
3651
+ }
3652
+ return str;
3653
+ }
3654
+ simpleKeybindingToScanCodeBinding(keybinding) {
3655
+ if (keybinding.keyCode === 3 ) {
3656
+ return [( (new ScanCodeBinding(
3657
+ keybinding.ctrlKey,
3658
+ keybinding.shiftKey,
3659
+ keybinding.altKey,
3660
+ keybinding.metaKey,
3661
+ 46
3662
+ )))];
3663
+ }
3664
+ const scanCodeCombos = this._scanCodeKeyCodeMapper.lookupKeyCodeCombo(( (new KeyCodeCombo(
3665
+ keybinding.ctrlKey,
3666
+ keybinding.shiftKey,
3667
+ keybinding.altKey,
3668
+ keybinding.keyCode
3669
+ ))));
3670
+ const result = [];
3671
+ for (let i = 0, len = scanCodeCombos.length; i < len; i++) {
3672
+ const scanCodeCombo = scanCodeCombos[i];
3673
+ result[i] = ( (new ScanCodeBinding(
3674
+ scanCodeCombo.ctrlKey,
3675
+ scanCodeCombo.shiftKey,
3676
+ scanCodeCombo.altKey,
3677
+ keybinding.metaKey,
3678
+ scanCodeCombo.scanCode
3679
+ )));
3680
+ }
3681
+ return result;
3682
+ }
3683
+ getUILabelForScanCodeBinding(binding) {
3684
+ if (!binding) {
3685
+ return null;
3686
+ }
3687
+ if (binding.isDuplicateModifierCase()) {
3688
+ return '';
3689
+ }
3690
+ if (this._OS === 2 ) {
3691
+ switch (binding.scanCode) {
3692
+ case 86 :
3693
+ return '←';
3694
+ case 88 :
3695
+ return '↑';
3696
+ case 85 :
3697
+ return '→';
3698
+ case 87 :
3699
+ return '↓';
3700
+ }
3701
+ }
3702
+ return this._scanCodeToLabel[binding.scanCode];
3703
+ }
3704
+ getAriaLabelForScanCodeBinding(binding) {
3705
+ if (!binding) {
3706
+ return null;
3707
+ }
3708
+ if (binding.isDuplicateModifierCase()) {
3709
+ return '';
3710
+ }
3711
+ return this._scanCodeToLabel[binding.scanCode];
3712
+ }
3713
+ getDispatchStrForScanCodeBinding(keypress) {
3714
+ const codeDispatch = this._scanCodeToDispatch[keypress.scanCode];
3715
+ if (!codeDispatch) {
3716
+ return null;
3717
+ }
3718
+ let result = '';
3719
+ if (keypress.ctrlKey) {
3720
+ result += 'ctrl+';
3721
+ }
3722
+ if (keypress.shiftKey) {
3723
+ result += 'shift+';
3724
+ }
3725
+ if (keypress.altKey) {
3726
+ result += 'alt+';
3727
+ }
3728
+ if (keypress.metaKey) {
3729
+ result += 'meta+';
3730
+ }
3731
+ result += codeDispatch;
3732
+ return result;
3733
+ }
3734
+ getUserSettingsLabelForScanCodeBinding(binding) {
3735
+ if (!binding) {
3736
+ return null;
3737
+ }
3738
+ if (binding.isDuplicateModifierCase()) {
3739
+ return '';
3740
+ }
3741
+ const immutableKeyCode = IMMUTABLE_CODE_TO_KEY_CODE[binding.scanCode];
3742
+ if (immutableKeyCode !== -1 ) {
3743
+ return KeyCodeUtils.toUserSettingsUS(immutableKeyCode).toLowerCase();
3744
+ }
3745
+ const constantKeyCode = this._scanCodeKeyCodeMapper.guessStableKeyCode(binding.scanCode);
3746
+ if (constantKeyCode !== -1 ) {
3747
+ const reverseBindings = this.simpleKeybindingToScanCodeBinding(( (new SimpleKeybinding(
3748
+ binding.ctrlKey,
3749
+ binding.shiftKey,
3750
+ binding.altKey,
3751
+ binding.metaKey,
3752
+ constantKeyCode
3753
+ ))));
3754
+ for (let i = 0, len = reverseBindings.length; i < len; i++) {
3755
+ const reverseBinding = reverseBindings[i];
3756
+ if (reverseBinding.scanCode === binding.scanCode) {
3757
+ return KeyCodeUtils.toUserSettingsUS(constantKeyCode).toLowerCase();
3758
+ }
3759
+ }
3760
+ }
3761
+ return this._scanCodeToDispatch[binding.scanCode];
3762
+ }
3763
+ getElectronAcceleratorLabelForScanCodeBinding(binding) {
3764
+ if (!binding) {
3765
+ return null;
3766
+ }
3767
+ const immutableKeyCode = IMMUTABLE_CODE_TO_KEY_CODE[binding.scanCode];
3768
+ if (immutableKeyCode !== -1 ) {
3769
+ return KeyCodeUtils.toElectronAccelerator(immutableKeyCode);
3770
+ }
3771
+ const constantKeyCode = this._scanCodeKeyCodeMapper.guessStableKeyCode(binding.scanCode);
3772
+ if (this._OS === 3 && !this._isUSStandard) {
3773
+ const isOEMKey = ((constantKeyCode === 80
3774
+ || constantKeyCode === 81
3775
+ || constantKeyCode === 82
3776
+ || constantKeyCode === 83
3777
+ || constantKeyCode === 84
3778
+ || constantKeyCode === 85
3779
+ || constantKeyCode === 86
3780
+ || constantKeyCode === 87
3781
+ || constantKeyCode === 88 || constantKeyCode === 89) );
3782
+ if (isOEMKey) {
3783
+ return null;
3784
+ }
3785
+ }
3786
+ if (constantKeyCode !== -1 ) {
3787
+ return KeyCodeUtils.toElectronAccelerator(constantKeyCode);
3788
+ }
3789
+ return null;
3790
+ }
3791
+ resolveKeybinding(keybinding) {
3792
+ const chordParts = [];
3793
+ for (const part of keybinding.parts) {
3794
+ chordParts.push(this.simpleKeybindingToScanCodeBinding(part));
3795
+ }
3796
+ return this._toResolvedKeybinding(chordParts);
3797
+ }
3798
+ _toResolvedKeybinding(chordParts) {
3799
+ if (chordParts.length === 0) {
3800
+ return [];
3801
+ }
3802
+ const result = [];
3803
+ this._generateResolvedKeybindings(chordParts, 0, [], result);
3804
+ return result;
3805
+ }
3806
+ _generateResolvedKeybindings(chordParts, currentIndex, previousParts, result) {
3807
+ const chordPart = chordParts[currentIndex];
3808
+ const isFinalIndex = currentIndex === chordParts.length - 1;
3809
+ for (let i = 0, len = chordPart.length; i < len; i++) {
3810
+ const chords = [...previousParts, chordPart[i]];
3811
+ if (isFinalIndex) {
3812
+ result.push(( (new NativeResolvedKeybinding(this, this._OS, chords))));
3813
+ }
3814
+ else {
3815
+ this._generateResolvedKeybindings(chordParts, currentIndex + 1, chords, result);
3816
+ }
3817
+ }
3818
+ }
3819
+ resolveKeyboardEvent(keyboardEvent) {
3820
+ let code = ScanCodeUtils.toEnum(keyboardEvent.code);
3821
+ if (code === 94 ) {
3822
+ code = 46 ;
3823
+ }
3824
+ const keyCode = keyboardEvent.keyCode;
3825
+ if (((keyCode === 15) )
3826
+ || ((keyCode === 16) )
3827
+ || ((keyCode === 17) )
3828
+ || ((keyCode === 18) )
3829
+ || ((keyCode === 20) )
3830
+ || ((keyCode === 19) )
3831
+ || ((keyCode === 14) )
3832
+ || ((keyCode === 13) )
3833
+ || ((keyCode === 12) )
3834
+ || ((keyCode === 11) )
3835
+ || ((keyCode === 1) )) {
3836
+ const immutableScanCode = IMMUTABLE_KEY_CODE_TO_CODE[keyCode];
3837
+ if (immutableScanCode !== -1 ) {
3838
+ code = immutableScanCode;
3839
+ }
3840
+ }
3841
+ else {
3842
+ if (((code === 95) )
3843
+ || ((code === 96) )
3844
+ || ((code === 97) )
3845
+ || ((code === 98) )
3846
+ || ((code === 99) )
3847
+ || ((code === 100) )
3848
+ || ((code === 101) )
3849
+ || ((code === 102) )
3850
+ || ((code === 103) )
3851
+ || ((code === 104) )
3852
+ || ((code === 105) )) {
3853
+ if (keyCode >= 0) {
3854
+ const immutableScanCode = IMMUTABLE_KEY_CODE_TO_CODE[keyCode];
3855
+ if (immutableScanCode !== -1 ) {
3856
+ code = immutableScanCode;
3857
+ }
3858
+ }
3859
+ }
3860
+ }
3861
+ const keypress = ( (new ScanCodeBinding(
3862
+ keyboardEvent.ctrlKey,
3863
+ keyboardEvent.shiftKey,
3864
+ keyboardEvent.altKey,
3865
+ keyboardEvent.metaKey,
3866
+ code
3867
+ )));
3868
+ return (
3869
+ (new NativeResolvedKeybinding(this, this._OS, [keypress]))
3870
+ );
3871
+ }
3872
+ _resolveSimpleUserBinding(binding) {
3873
+ if (!binding) {
3874
+ return [];
3875
+ }
3876
+ if (binding instanceof ScanCodeBinding) {
3877
+ return [binding];
3878
+ }
3879
+ return this.simpleKeybindingToScanCodeBinding(binding);
3880
+ }
3881
+ resolveUserBinding(input) {
3882
+ const parts = input.map(keybinding => this._resolveSimpleUserBinding(keybinding));
3883
+ return this._toResolvedKeybinding(parts);
3884
+ }
3885
+ static _redirectCharCode(charCode) {
3886
+ switch (charCode) {
3887
+ case 12290 : return 46 ;
3888
+ case 12300 : return 91 ;
3889
+ case 12301 : return 93 ;
3890
+ case 12304 : return 91 ;
3891
+ case 12305 : return 93 ;
3892
+ case 65307 : return 59 ;
3893
+ case 65292 : return 44 ;
3894
+ }
3895
+ return charCode;
3896
+ }
3897
+ static _charCodeToKb(charCode) {
3898
+ charCode = this._redirectCharCode(charCode);
3899
+ if (charCode < CHAR_CODE_TO_KEY_CODE.length) {
3900
+ return CHAR_CODE_TO_KEY_CODE[charCode];
3901
+ }
3902
+ return null;
3903
+ }
3904
+ static getCharCode(char) {
3905
+ if (char.length === 0) {
3906
+ return 0;
3907
+ }
3908
+ const charCode = char.charCodeAt(0);
3909
+ switch (charCode) {
3910
+ case 768 : return 96 ;
3911
+ case 769 : return 180 ;
3912
+ case 770 : return 94 ;
3913
+ case 771 : return 732 ;
3914
+ case 772 : return 175 ;
3915
+ case 773 : return 8254 ;
3916
+ case 774 : return 728 ;
3917
+ case 775 : return 729 ;
3918
+ case 776 : return 168 ;
3919
+ case 778 : return 730 ;
3920
+ case 779 : return 733 ;
3921
+ }
3922
+ return charCode;
3923
+ }
3924
+ }
3925
+ (function () {
3926
+ function define(charCode, keyCode, shiftKey) {
3927
+ for (let i = CHAR_CODE_TO_KEY_CODE.length; i < charCode; i++) {
3928
+ CHAR_CODE_TO_KEY_CODE[i] = null;
3929
+ }
3930
+ CHAR_CODE_TO_KEY_CODE[charCode] = { keyCode: keyCode, shiftKey: shiftKey };
3931
+ }
3932
+ for (let chCode = 65 ; chCode <= 90 ; chCode++) {
3933
+ define(chCode, 31 + ((chCode - 65) ), true);
3934
+ }
3935
+ for (let chCode = 97 ; chCode <= 122 ; chCode++) {
3936
+ define(chCode, 31 + ((chCode - 97) ), false);
3937
+ }
3938
+ define(59 , 80 , false);
3939
+ define(58 , 80 , true);
3940
+ define(61 , 81 , false);
3941
+ define(43 , 81 , true);
3942
+ define(44 , 82 , false);
3943
+ define(60 , 82 , true);
3944
+ define(45 , 83 , false);
3945
+ define(95 , 83 , true);
3946
+ define(46 , 84 , false);
3947
+ define(62 , 84 , true);
3948
+ define(47 , 85 , false);
3949
+ define(63 , 85 , true);
3950
+ define(96 , 86 , false);
3951
+ define(126 , 86 , true);
3952
+ define(91 , 87 , false);
3953
+ define(123 , 87 , true);
3954
+ define(92 , 88 , false);
3955
+ define(124 , 88 , true);
3956
+ define(93 , 89 , false);
3957
+ define(125 , 89 , true);
3958
+ define(39 , 90 , false);
3959
+ define(34 , 90 , true);
3960
+ })();
3961
+ function __variableDynamicImportRuntime0__(path) {
3962
+ switch (path) {
3963
+ case './keyboardLayouts/layout.contribution.darwin.js': return import('./layout.contribution.darwin.js').then(module => module.default ?? module);
3964
+ case './keyboardLayouts/layout.contribution.linux.js': return import('./layout.contribution.linux.js').then(module => module.default ?? module);
3965
+ case './keyboardLayouts/layout.contribution.win.js': return import('./layout.contribution.win.js').then(module => module.default ?? module);
3966
+ default: return new Promise(function(resolve, reject) {
3967
+ (typeof queueMicrotask === 'function' ? queueMicrotask : setTimeout)(
3968
+ reject.bind(null, new Error("Unknown variable dynamic import: " + path))
3969
+ );
3970
+ })
3971
+ }
3972
+ }
3973
+ class BrowserKeyboardMapperFactoryBase {
3974
+ constructor(
3975
+ ) {
3976
+ this._onDidChangeKeyboardMapper = ( (new Emitter()));
3977
+ this.onDidChangeKeyboardMapper = this._onDidChangeKeyboardMapper.event;
3978
+ this._keyboardMapper = null;
3979
+ this._initialized = false;
3980
+ this._keymapInfos = [];
3981
+ this._mru = [];
3982
+ this._activeKeymapInfo = null;
3983
+ if (navigator.keyboard && navigator.keyboard.addEventListener) {
3984
+ navigator.keyboard.addEventListener('layoutchange', () => {
3985
+ this._getBrowserKeyMapping().then((mapping) => {
3986
+ if (this.isKeyMappingActive(mapping)) {
3987
+ return;
3988
+ }
3989
+ this.setLayoutFromBrowserAPI();
3990
+ });
3991
+ });
3992
+ }
3993
+ }
3994
+ get activeKeymap() {
3995
+ return this._activeKeymapInfo;
3996
+ }
3997
+ get keymapInfos() {
3998
+ return this._keymapInfos;
3999
+ }
4000
+ get activeKeyboardLayout() {
4001
+ if (!this._initialized) {
4002
+ return null;
4003
+ }
4004
+ return this._activeKeymapInfo && this._activeKeymapInfo.layout;
4005
+ }
4006
+ get activeKeyMapping() {
4007
+ if (!this._initialized) {
4008
+ return null;
4009
+ }
4010
+ return this._activeKeymapInfo && this._activeKeymapInfo.mapping;
4011
+ }
4012
+ get keyboardLayouts() {
4013
+ return this._keymapInfos.map(keymapInfo => keymapInfo.layout);
4014
+ }
4015
+ registerKeyboardLayout(layout) {
4016
+ this._keymapInfos.push(layout);
4017
+ this._mru = this._keymapInfos;
4018
+ }
4019
+ removeKeyboardLayout(layout) {
4020
+ let index = this._mru.indexOf(layout);
4021
+ this._mru.splice(index, 1);
4022
+ index = this._keymapInfos.indexOf(layout);
4023
+ this._keymapInfos.splice(index, 1);
4024
+ }
4025
+ getMatchedKeymapInfo(keyMapping) {
4026
+ if (!keyMapping) {
4027
+ return null;
4028
+ }
4029
+ const usStandard = this.getUSStandardLayout();
4030
+ if (usStandard) {
4031
+ let maxScore = usStandard.getScore(keyMapping);
4032
+ if (maxScore === 0) {
4033
+ return {
4034
+ result: usStandard,
4035
+ score: 0
4036
+ };
4037
+ }
4038
+ let result = usStandard;
4039
+ for (let i = 0; i < this._mru.length; i++) {
4040
+ const score = this._mru[i].getScore(keyMapping);
4041
+ if (score > maxScore) {
4042
+ if (score === 0) {
4043
+ return {
4044
+ result: this._mru[i],
4045
+ score: 0
4046
+ };
4047
+ }
4048
+ maxScore = score;
4049
+ result = this._mru[i];
4050
+ }
4051
+ }
4052
+ return {
4053
+ result,
4054
+ score: maxScore
4055
+ };
4056
+ }
4057
+ for (let i = 0; i < this._mru.length; i++) {
4058
+ if (this._mru[i].fuzzyEqual(keyMapping)) {
4059
+ return {
4060
+ result: this._mru[i],
4061
+ score: 0
4062
+ };
4063
+ }
4064
+ }
4065
+ return null;
4066
+ }
4067
+ getUSStandardLayout() {
4068
+ const usStandardLayouts = this._mru.filter(layout => layout.layout.isUSStandard);
4069
+ if (usStandardLayouts.length) {
4070
+ return usStandardLayouts[0];
4071
+ }
4072
+ return null;
4073
+ }
4074
+ isKeyMappingActive(keymap) {
4075
+ return this._activeKeymapInfo && keymap && this._activeKeymapInfo.fuzzyEqual(keymap);
4076
+ }
4077
+ setUSKeyboardLayout() {
4078
+ this._activeKeymapInfo = this.getUSStandardLayout();
4079
+ }
4080
+ setActiveKeyMapping(keymap) {
4081
+ let keymapUpdated = false;
4082
+ const matchedKeyboardLayout = this.getMatchedKeymapInfo(keymap);
4083
+ if (matchedKeyboardLayout) {
4084
+ if (!this._activeKeymapInfo) {
4085
+ this._activeKeymapInfo = matchedKeyboardLayout.result;
4086
+ keymapUpdated = true;
4087
+ }
4088
+ else if (keymap) {
4089
+ if (matchedKeyboardLayout.result.getScore(keymap) > this._activeKeymapInfo.getScore(keymap)) {
4090
+ this._activeKeymapInfo = matchedKeyboardLayout.result;
4091
+ keymapUpdated = true;
4092
+ }
4093
+ }
4094
+ }
4095
+ if (!this._activeKeymapInfo) {
4096
+ this._activeKeymapInfo = this.getUSStandardLayout();
4097
+ keymapUpdated = true;
4098
+ }
4099
+ if (!this._activeKeymapInfo || !keymapUpdated) {
4100
+ return;
4101
+ }
4102
+ const index = this._mru.indexOf(this._activeKeymapInfo);
4103
+ this._mru.splice(index, 1);
4104
+ this._mru.unshift(this._activeKeymapInfo);
4105
+ this._setKeyboardData(this._activeKeymapInfo);
4106
+ }
4107
+ setActiveKeymapInfo(keymapInfo) {
4108
+ this._activeKeymapInfo = keymapInfo;
4109
+ const index = this._mru.indexOf(this._activeKeymapInfo);
4110
+ if (index === 0) {
4111
+ return;
4112
+ }
4113
+ this._mru.splice(index, 1);
4114
+ this._mru.unshift(this._activeKeymapInfo);
4115
+ this._setKeyboardData(this._activeKeymapInfo);
4116
+ }
4117
+ setLayoutFromBrowserAPI() {
4118
+ this._updateKeyboardLayoutAsync(this._initialized);
4119
+ }
4120
+ _updateKeyboardLayoutAsync(initialized, keyboardEvent) {
4121
+ if (!initialized) {
4122
+ return;
4123
+ }
4124
+ this._getBrowserKeyMapping(keyboardEvent).then(keyMap => {
4125
+ if (this.isKeyMappingActive(keyMap)) {
4126
+ return;
4127
+ }
4128
+ this.setActiveKeyMapping(keyMap);
4129
+ });
4130
+ }
4131
+ getKeyboardMapper(dispatchConfig) {
4132
+ if (!this._initialized) {
4133
+ return (
4134
+ (new MacLinuxFallbackKeyboardMapper(OS))
4135
+ );
4136
+ }
4137
+ if (dispatchConfig === 1 ) {
4138
+ return (
4139
+ (new MacLinuxFallbackKeyboardMapper(OS))
4140
+ );
4141
+ }
4142
+ return this._keyboardMapper;
4143
+ }
4144
+ validateCurrentKeyboardMapping(keyboardEvent) {
4145
+ if (!this._initialized) {
4146
+ return;
4147
+ }
4148
+ const isCurrentKeyboard = this._validateCurrentKeyboardMapping(keyboardEvent);
4149
+ if (isCurrentKeyboard) {
4150
+ return;
4151
+ }
4152
+ this._updateKeyboardLayoutAsync(true, keyboardEvent);
4153
+ }
4154
+ setKeyboardLayout(layoutName) {
4155
+ const matchedLayouts = this.keymapInfos.filter(keymapInfo => getKeyboardLayoutId(keymapInfo.layout) === layoutName);
4156
+ if (matchedLayouts.length > 0) {
4157
+ this.setActiveKeymapInfo(matchedLayouts[0]);
4158
+ }
4159
+ }
4160
+ _setKeyboardData(keymapInfo) {
4161
+ this._initialized = true;
4162
+ this._keyboardMapper = ( (new CachedKeyboardMapper(BrowserKeyboardMapperFactory._createKeyboardMapper(keymapInfo))));
4163
+ this._onDidChangeKeyboardMapper.fire();
4164
+ }
4165
+ static _createKeyboardMapper(keymapInfo) {
4166
+ const rawMapping = keymapInfo.mapping;
4167
+ const isUSStandard = !!keymapInfo.layout.isUSStandard;
4168
+ if (OS === 1 ) {
4169
+ return (
4170
+ (new WindowsKeyboardMapper(isUSStandard, rawMapping))
4171
+ );
4172
+ }
4173
+ if (( (Object.keys(rawMapping))).length === 0) {
4174
+ return (
4175
+ (new MacLinuxFallbackKeyboardMapper(OS))
4176
+ );
4177
+ }
4178
+ return (
4179
+ (new MacLinuxKeyboardMapper(isUSStandard, rawMapping, OS))
4180
+ );
4181
+ }
4182
+ _validateCurrentKeyboardMapping(keyboardEvent) {
4183
+ if (!this._initialized) {
4184
+ return true;
4185
+ }
4186
+ const standardKeyboardEvent = keyboardEvent;
4187
+ const currentKeymap = this._activeKeymapInfo;
4188
+ if (!currentKeymap) {
4189
+ return true;
4190
+ }
4191
+ if (standardKeyboardEvent.browserEvent.key === 'Dead' || standardKeyboardEvent.browserEvent.isComposing) {
4192
+ return true;
4193
+ }
4194
+ const mapping = currentKeymap.mapping[standardKeyboardEvent.code];
4195
+ if (!mapping) {
4196
+ return false;
4197
+ }
4198
+ if (mapping.value === '') {
4199
+ if (keyboardEvent.ctrlKey || keyboardEvent.metaKey) {
4200
+ setTimeout(() => {
4201
+ this._getBrowserKeyMapping().then((keymap) => {
4202
+ if (this.isKeyMappingActive(keymap)) {
4203
+ return;
4204
+ }
4205
+ this.setLayoutFromBrowserAPI();
4206
+ });
4207
+ }, 350);
4208
+ }
4209
+ return true;
4210
+ }
4211
+ const expectedValue = standardKeyboardEvent.altKey && standardKeyboardEvent.shiftKey ? mapping.withShiftAltGr :
4212
+ standardKeyboardEvent.altKey ? mapping.withAltGr :
4213
+ standardKeyboardEvent.shiftKey ? mapping.withShift : mapping.value;
4214
+ const isDead = (standardKeyboardEvent.altKey && standardKeyboardEvent.shiftKey && mapping.withShiftAltGrIsDeadKey) ||
4215
+ (standardKeyboardEvent.altKey && mapping.withAltGrIsDeadKey) ||
4216
+ (standardKeyboardEvent.shiftKey && mapping.withShiftIsDeadKey) ||
4217
+ mapping.valueIsDeadKey;
4218
+ if (isDead && standardKeyboardEvent.browserEvent.key !== 'Dead') {
4219
+ return false;
4220
+ }
4221
+ if (!isDead && standardKeyboardEvent.browserEvent.key !== expectedValue) {
4222
+ return false;
4223
+ }
4224
+ return true;
4225
+ }
4226
+ async _getBrowserKeyMapping(keyboardEvent) {
4227
+ if (navigator.keyboard) {
4228
+ try {
4229
+ return navigator.keyboard.getLayoutMap().then((e) => {
4230
+ const ret = {};
4231
+ for (const key of e) {
4232
+ ret[key[0]] = {
4233
+ 'value': key[1],
4234
+ 'withShift': '',
4235
+ 'withAltGr': '',
4236
+ 'withShiftAltGr': ''
4237
+ };
4238
+ }
4239
+ return ret;
4240
+ });
4241
+ }
4242
+ catch {
4243
+ }
4244
+ }
4245
+ else if (keyboardEvent && !keyboardEvent.shiftKey && !keyboardEvent.altKey && !keyboardEvent.metaKey && !keyboardEvent.metaKey) {
4246
+ const ret = {};
4247
+ const standardKeyboardEvent = keyboardEvent;
4248
+ ret[standardKeyboardEvent.browserEvent.code] = {
4249
+ 'value': standardKeyboardEvent.browserEvent.key,
4250
+ 'withShift': '',
4251
+ 'withAltGr': '',
4252
+ 'withShiftAltGr': ''
4253
+ };
4254
+ const matchedKeyboardLayout = this.getMatchedKeymapInfo(ret);
4255
+ if (matchedKeyboardLayout) {
4256
+ return ret;
4257
+ }
4258
+ return null;
4259
+ }
4260
+ return null;
4261
+ }
4262
+ }
4263
+ class BrowserKeyboardMapperFactory extends BrowserKeyboardMapperFactoryBase {
4264
+ constructor(notificationService, storageService, commandService) {
4265
+ super();
4266
+ const platform = isWindows ? 'win' : isMacintosh ? 'darwin' : 'linux';
4267
+ __variableDynamicImportRuntime0__('./keyboardLayouts/layout.contribution.' + platform + '.js').then((m) => {
4268
+ const keymapInfos = m.KeyboardLayoutContribution.INSTANCE.layoutInfos;
4269
+ this._keymapInfos.push(...keymapInfos.map(info => (( (new KeymapInfo(
4270
+ info.layout,
4271
+ info.secondaryLayouts,
4272
+ info.mapping,
4273
+ info.isUserKeyboardLayout
4274
+ ))))));
4275
+ this._mru = this._keymapInfos;
4276
+ this._initialized = true;
4277
+ this.setLayoutFromBrowserAPI();
4278
+ });
4279
+ }
4280
+ }
4281
+ class UserKeyboardLayout extends Disposable {
4282
+ constructor(keyboardLayoutResource, fileService) {
4283
+ super();
4284
+ this.keyboardLayoutResource = keyboardLayoutResource;
4285
+ this.fileService = fileService;
4286
+ this._onDidChange = this._register(( (new Emitter())));
4287
+ this.onDidChange = this._onDidChange.event;
4288
+ this._keyboardLayout = null;
4289
+ this.reloadConfigurationScheduler = this._register(( (new RunOnceScheduler(() => this.reload().then(changed => {
4290
+ if (changed) {
4291
+ this._onDidChange.fire();
4292
+ }
4293
+ }), 50))));
4294
+ this._register(Event.filter(this.fileService.onDidFilesChange, e => e.contains(this.keyboardLayoutResource))(() => this.reloadConfigurationScheduler.schedule()));
4295
+ }
4296
+ get keyboardLayout() { return this._keyboardLayout; }
4297
+ async initialize() {
4298
+ await this.reload();
4299
+ }
4300
+ async reload() {
4301
+ const existing = this._keyboardLayout;
4302
+ try {
4303
+ const content = await this.fileService.readFile(this.keyboardLayoutResource);
4304
+ const value = parse(( (content.value.toString())));
4305
+ if (getNodeType(value) === 'object') {
4306
+ const layoutInfo = value.layout;
4307
+ const mappings = value.rawMapping;
4308
+ this._keyboardLayout = KeymapInfo.createKeyboardLayoutFromDebugInfo(layoutInfo, mappings, true);
4309
+ }
4310
+ else {
4311
+ this._keyboardLayout = null;
4312
+ }
4313
+ }
4314
+ catch (e) {
4315
+ this._keyboardLayout = null;
4316
+ }
4317
+ return existing ? !equals(existing, this._keyboardLayout) : true;
4318
+ }
4319
+ }
4320
+ let BrowserKeyboardLayoutService = class BrowserKeyboardLayoutService extends Disposable {
4321
+ constructor(environmentService, fileService, notificationService, storageService, commandService, configurationService) {
4322
+ super();
4323
+ this.configurationService = configurationService;
4324
+ this._onDidChangeKeyboardLayout = ( (new Emitter()));
4325
+ this.onDidChangeKeyboardLayout = this._onDidChangeKeyboardLayout.event;
4326
+ const keyboardConfig = configurationService.getValue('keyboard');
4327
+ const layout = keyboardConfig.layout;
4328
+ this._keyboardLayoutMode = layout ?? 'autodetect';
4329
+ this._factory = ( (new BrowserKeyboardMapperFactory(notificationService, storageService, commandService)));
4330
+ this._register(this._factory.onDidChangeKeyboardMapper(() => {
4331
+ this._onDidChangeKeyboardLayout.fire();
4332
+ }));
4333
+ if (layout && layout !== 'autodetect') {
4334
+ this._factory.setKeyboardLayout(layout);
4335
+ }
4336
+ this._register(configurationService.onDidChangeConfiguration(e => {
4337
+ if (e.affectedKeys.indexOf('keyboard.layout') >= 0) {
4338
+ const keyboardConfig = configurationService.getValue('keyboard');
4339
+ const layout = keyboardConfig.layout;
4340
+ this._keyboardLayoutMode = layout;
4341
+ if (layout === 'autodetect') {
4342
+ this._factory.setLayoutFromBrowserAPI();
4343
+ }
4344
+ else {
4345
+ this._factory.setKeyboardLayout(layout);
4346
+ }
4347
+ }
4348
+ }));
4349
+ this._userKeyboardLayout = ( (new UserKeyboardLayout(environmentService.keyboardLayoutResource, fileService)));
4350
+ this._userKeyboardLayout.initialize().then(() => {
4351
+ if (this._userKeyboardLayout.keyboardLayout) {
4352
+ this._factory.registerKeyboardLayout(this._userKeyboardLayout.keyboardLayout);
4353
+ this.setUserKeyboardLayoutIfMatched();
4354
+ }
4355
+ });
4356
+ this._register(this._userKeyboardLayout.onDidChange(() => {
4357
+ const userKeyboardLayouts = this._factory.keymapInfos.filter(layout => layout.isUserKeyboardLayout);
4358
+ if (userKeyboardLayouts.length) {
4359
+ if (this._userKeyboardLayout.keyboardLayout) {
4360
+ userKeyboardLayouts[0].update(this._userKeyboardLayout.keyboardLayout);
4361
+ }
4362
+ else {
4363
+ this._factory.removeKeyboardLayout(userKeyboardLayouts[0]);
4364
+ }
4365
+ }
4366
+ else {
4367
+ if (this._userKeyboardLayout.keyboardLayout) {
4368
+ this._factory.registerKeyboardLayout(this._userKeyboardLayout.keyboardLayout);
4369
+ }
4370
+ }
4371
+ this.setUserKeyboardLayoutIfMatched();
4372
+ }));
4373
+ }
4374
+ setUserKeyboardLayoutIfMatched() {
4375
+ const keyboardConfig = this.configurationService.getValue('keyboard');
4376
+ const layout = keyboardConfig.layout;
4377
+ if (layout && this._userKeyboardLayout.keyboardLayout) {
4378
+ if (getKeyboardLayoutId(this._userKeyboardLayout.keyboardLayout.layout) === layout && this._factory.activeKeymap) {
4379
+ if (!this._userKeyboardLayout.keyboardLayout.equal(this._factory.activeKeymap)) {
4380
+ this._factory.setActiveKeymapInfo(this._userKeyboardLayout.keyboardLayout);
4381
+ }
4382
+ }
4383
+ }
4384
+ }
4385
+ getKeyboardMapper(dispatchConfig) {
4386
+ return this._factory.getKeyboardMapper(dispatchConfig);
4387
+ }
4388
+ getCurrentKeyboardLayout() {
4389
+ return this._factory.activeKeyboardLayout;
4390
+ }
4391
+ getAllKeyboardLayouts() {
4392
+ return this._factory.keyboardLayouts;
4393
+ }
4394
+ getRawKeyboardMapping() {
4395
+ return this._factory.activeKeyMapping;
4396
+ }
4397
+ validateCurrentKeyboardMapping(keyboardEvent) {
4398
+ if (this._keyboardLayoutMode !== 'autodetect') {
4399
+ return;
4400
+ }
4401
+ this._factory.validateCurrentKeyboardMapping(keyboardEvent);
4402
+ }
4403
+ };
4404
+ BrowserKeyboardLayoutService = ( (__decorate([
4405
+ ( (__param(0, IEnvironmentService))),
4406
+ ( (__param(1, IFileService))),
4407
+ ( (__param(2, INotificationService))),
4408
+ ( (__param(3, IStorageService))),
4409
+ ( (__param(4, ICommandService))),
4410
+ ( (__param(5, IConfigurationService)))
4411
+ ], BrowserKeyboardLayoutService)));
4412
+ const configurationRegistry = ( (Registry.as(Extensions$1.Configuration)));
4413
+ const keyboardConfiguration = {
4414
+ 'id': 'keyboard',
4415
+ 'order': 15,
4416
+ 'type': 'object',
4417
+ 'title': ( (localize('keyboardConfigurationTitle', "Keyboard"))),
4418
+ 'properties': {
4419
+ 'keyboard.layout': {
4420
+ 'type': 'string',
4421
+ 'default': 'autodetect',
4422
+ 'description': ( (localize('keyboard.layout.config', "Control the keyboard layout used in web.")))
4423
+ }
4424
+ }
4425
+ };
4426
+ configurationRegistry.registerConfiguration(keyboardConfiguration);
2290
4427
  let DelegateStandaloneKeybindingService = class DelegateStandaloneKeybindingService extends createInjectedClass(StandaloneKeybindingService) {
2291
4428
  constructor(instantiationService) {
2292
4429
  super(instantiationService);
@@ -2347,7 +4484,8 @@ function updateUserKeybindings(keybindingsJson) {
2347
4484
  function getServiceOverride() {
2348
4485
  return {
2349
4486
  ...getServiceOverride$1(),
2350
- [( IKeybindingService.toString())]: new SyncDescriptor(DelegateStandaloneKeybindingService)
4487
+ [( IKeybindingService.toString())]: new SyncDescriptor(DelegateStandaloneKeybindingService),
4488
+ [( IKeyboardLayoutService.toString())]: new SyncDescriptor(BrowserKeyboardLayoutService)
2351
4489
  };
2352
4490
  }
2353
4491
  export { getServiceOverride as default, setCommands, setKeybindings, updateUserKeybindings };