@codingame/monaco-vscode-keybindings-service-override 4.1.0 → 4.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/keybindings.js +6 -6
  2. package/package.json +9 -9
  3. package/vscode/src/vs/platform/keyboardLayout/common/keyboardConfig.js +50 -0
  4. package/vscode/src/vs/platform/keyboardLayout/common/keyboardMapper.js +24 -0
  5. package/vscode/src/vs/workbench/contrib/commands/common/commands.contribution.js +146 -0
  6. package/vscode/src/vs/workbench/contrib/keybindings/browser/keybindings.contribution.js +29 -0
  7. package/vscode/src/vs/workbench/contrib/preferences/browser/keybindingsEditorContribution.js +250 -0
  8. package/vscode/src/vs/workbench/contrib/preferences/common/smartSnippetInserter.js +126 -0
  9. package/vscode/src/vs/workbench/services/actions/common/menusExtensionPoint.js +1597 -0
  10. package/vscode/src/vs/workbench/services/commands/common/commandService.js +79 -0
  11. package/vscode/src/vs/workbench/services/keybinding/browser/keybindingService.js +947 -0
  12. package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayoutService.js +502 -0
  13. package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/_.contribution.js +14 -0
  14. package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/cz.win.js +163 -0
  15. package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/de-swiss.win.js +163 -0
  16. package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/de.darwin.js +126 -0
  17. package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/de.linux.js +181 -0
  18. package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/de.win.js +163 -0
  19. package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/dk.win.js +163 -0
  20. package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/dvorak.darwin.js +126 -0
  21. package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/en-belgian.win.js +163 -0
  22. package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/en-ext.darwin.js +126 -0
  23. package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/en-in.win.js +163 -0
  24. package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/en-intl.darwin.js +126 -0
  25. package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/en-intl.win.js +163 -0
  26. package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/en-uk.darwin.js +126 -0
  27. package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/en-uk.win.js +163 -0
  28. package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/en.darwin.js +134 -0
  29. package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/en.linux.js +183 -0
  30. package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/en.win.js +168 -0
  31. package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/es-latin.win.js +163 -0
  32. package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/es.darwin.js +126 -0
  33. package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/es.linux.js +181 -0
  34. package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/es.win.js +163 -0
  35. package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/fr.darwin.js +126 -0
  36. package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/fr.linux.js +181 -0
  37. package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/fr.win.js +163 -0
  38. package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/hu.win.js +163 -0
  39. package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/it.darwin.js +126 -0
  40. package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/it.win.js +163 -0
  41. package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/jp-roman.darwin.js +126 -0
  42. package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/jp.darwin.js +126 -0
  43. package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/ko.darwin.js +126 -0
  44. package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/layout.contribution.darwin.js +17 -0
  45. package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/layout.contribution.linux.js +6 -0
  46. package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/layout.contribution.win.js +23 -0
  47. package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/no.win.js +163 -0
  48. package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/pl.darwin.js +126 -0
  49. package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/pl.win.js +163 -0
  50. package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/pt-br.win.js +163 -0
  51. package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/pt.darwin.js +126 -0
  52. package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/pt.win.js +163 -0
  53. package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/ru.darwin.js +126 -0
  54. package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/ru.linux.js +181 -0
  55. package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/ru.win.js +163 -0
  56. package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/sv.win.js +165 -0
  57. package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/thai.win.js +163 -0
  58. package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/tr.win.js +163 -0
  59. package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/zh-hans.darwin.js +126 -0
  60. package/vscode/src/vs/workbench/services/keybinding/common/keybindingIO.js +74 -0
  61. package/vscode/src/vs/workbench/services/keybinding/common/keymapInfo.js +110 -0
  62. package/vscode/src/vs/workbench/services/keybinding/common/macLinuxKeyboardMapper.js +888 -0
  63. package/vscode/src/vs/workbench/services/keybinding/common/windowsKeyboardMapper.js +352 -0
@@ -0,0 +1,502 @@
1
+ import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
+ import { localizeWithPath } from 'vscode/vscode/vs/nls';
3
+ import { Emitter, Event } from 'vscode/vscode/vs/base/common/event';
4
+ import { Disposable } from 'vscode/vscode/vs/base/common/lifecycle';
5
+ import { KeymapInfo } from '../common/keymapInfo.js';
6
+ import { readKeyboardConfig } from '../../../../platform/keyboardLayout/common/keyboardConfig.js';
7
+ import { CachedKeyboardMapper } from '../../../../platform/keyboardLayout/common/keyboardMapper.js';
8
+ import { OS, isWindows, isMacintosh } from 'vscode/vscode/vs/base/common/platform';
9
+ import { WindowsKeyboardMapper } from '../common/windowsKeyboardMapper.js';
10
+ import { FallbackKeyboardMapper } from 'vscode/vscode/vs/workbench/services/keybinding/common/fallbackKeyboardMapper';
11
+ import { MacLinuxKeyboardMapper } from '../common/macLinuxKeyboardMapper.js';
12
+ import { IFileService } from 'vscode/vscode/vs/platform/files/common/files';
13
+ import { RunOnceScheduler } from 'vscode/vscode/vs/base/common/async';
14
+ import { parse, getNodeType } from 'vscode/vscode/vs/base/common/json';
15
+ import { equals } from 'vscode/vscode/vs/base/common/objects';
16
+ import { IEnvironmentService } from 'vscode/vscode/vs/platform/environment/common/environment';
17
+ import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
18
+ import { Extensions } from 'vscode/vscode/vs/platform/configuration/common/configurationRegistry';
19
+ import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration';
20
+ import { INotificationService } from 'vscode/vscode/vs/platform/notification/common/notification';
21
+ import { ICommandService } from 'vscode/vscode/vs/platform/commands/common/commands';
22
+ import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storage';
23
+ import { getKeyboardLayoutId } from 'vscode/vscode/vs/platform/keyboardLayout/common/keyboardLayout';
24
+
25
+ function __variableDynamicImportRuntime0__(path) {
26
+ switch (path) {
27
+ case './keyboardLayouts/layout.contribution.darwin.js': return import('./keyboardLayouts/layout.contribution.darwin.js').then(module => module.default ?? module);
28
+ case './keyboardLayouts/layout.contribution.linux.js': return import('./keyboardLayouts/layout.contribution.linux.js').then(module => module.default ?? module);
29
+ case './keyboardLayouts/layout.contribution.win.js': return import('./keyboardLayouts/layout.contribution.win.js').then(module => module.default ?? module);
30
+ default: return new Promise(function(resolve, reject) {
31
+ (typeof queueMicrotask === 'function' ? queueMicrotask : setTimeout)(
32
+ reject.bind(null, new Error("Unknown variable dynamic import: " + path))
33
+ );
34
+ })
35
+ }
36
+ }
37
+ class BrowserKeyboardMapperFactoryBase extends Disposable {
38
+ get activeKeymap() {
39
+ return this._activeKeymapInfo;
40
+ }
41
+ get keymapInfos() {
42
+ return this._keymapInfos;
43
+ }
44
+ get activeKeyboardLayout() {
45
+ if (!this._initialized) {
46
+ return null;
47
+ }
48
+ return this._activeKeymapInfo?.layout ?? null;
49
+ }
50
+ get activeKeyMapping() {
51
+ if (!this._initialized) {
52
+ return null;
53
+ }
54
+ return this._activeKeymapInfo?.mapping ?? null;
55
+ }
56
+ get keyboardLayouts() {
57
+ return ( this._keymapInfos.map(keymapInfo => keymapInfo.layout));
58
+ }
59
+ constructor(_configurationService) {
60
+ super();
61
+ this._configurationService = _configurationService;
62
+ this._onDidChangeKeyboardMapper = ( new Emitter());
63
+ this.onDidChangeKeyboardMapper = this._onDidChangeKeyboardMapper.event;
64
+ this.keyboardLayoutMapAllowed = navigator.keyboard !== undefined;
65
+ this._keyboardMapper = null;
66
+ this._initialized = false;
67
+ this._keymapInfos = [];
68
+ this._mru = [];
69
+ this._activeKeymapInfo = null;
70
+ if (navigator.keyboard && navigator.keyboard.addEventListener) {
71
+ navigator.keyboard.addEventListener('layoutchange', () => {
72
+ this._getBrowserKeyMapping().then((mapping) => {
73
+ if (this.isKeyMappingActive(mapping)) {
74
+ return;
75
+ }
76
+ this.setLayoutFromBrowserAPI();
77
+ });
78
+ });
79
+ }
80
+ this._register(this._configurationService.onDidChangeConfiguration((e) => {
81
+ if (e.affectsConfiguration('keyboard')) {
82
+ this._keyboardMapper = null;
83
+ this._onDidChangeKeyboardMapper.fire();
84
+ }
85
+ }));
86
+ }
87
+ registerKeyboardLayout(layout) {
88
+ this._keymapInfos.push(layout);
89
+ this._mru = this._keymapInfos;
90
+ }
91
+ removeKeyboardLayout(layout) {
92
+ let index = this._mru.indexOf(layout);
93
+ this._mru.splice(index, 1);
94
+ index = this._keymapInfos.indexOf(layout);
95
+ this._keymapInfos.splice(index, 1);
96
+ }
97
+ getMatchedKeymapInfo(keyMapping) {
98
+ if (!keyMapping) {
99
+ return null;
100
+ }
101
+ const usStandard = this.getUSStandardLayout();
102
+ if (usStandard) {
103
+ let maxScore = usStandard.getScore(keyMapping);
104
+ if (maxScore === 0) {
105
+ return {
106
+ result: usStandard,
107
+ score: 0
108
+ };
109
+ }
110
+ let result = usStandard;
111
+ for (let i = 0; i < this._mru.length; i++) {
112
+ const score = this._mru[i].getScore(keyMapping);
113
+ if (score > maxScore) {
114
+ if (score === 0) {
115
+ return {
116
+ result: this._mru[i],
117
+ score: 0
118
+ };
119
+ }
120
+ maxScore = score;
121
+ result = this._mru[i];
122
+ }
123
+ }
124
+ return {
125
+ result,
126
+ score: maxScore
127
+ };
128
+ }
129
+ for (let i = 0; i < this._mru.length; i++) {
130
+ if (this._mru[i].fuzzyEqual(keyMapping)) {
131
+ return {
132
+ result: this._mru[i],
133
+ score: 0
134
+ };
135
+ }
136
+ }
137
+ return null;
138
+ }
139
+ getUSStandardLayout() {
140
+ const usStandardLayouts = this._mru.filter(layout => layout.layout.isUSStandard);
141
+ if (usStandardLayouts.length) {
142
+ return usStandardLayouts[0];
143
+ }
144
+ return null;
145
+ }
146
+ isKeyMappingActive(keymap) {
147
+ return this._activeKeymapInfo && keymap && this._activeKeymapInfo.fuzzyEqual(keymap);
148
+ }
149
+ setUSKeyboardLayout() {
150
+ this._activeKeymapInfo = this.getUSStandardLayout();
151
+ }
152
+ setActiveKeyMapping(keymap) {
153
+ let keymapUpdated = false;
154
+ const matchedKeyboardLayout = this.getMatchedKeymapInfo(keymap);
155
+ if (matchedKeyboardLayout) {
156
+ if (!this._activeKeymapInfo) {
157
+ this._activeKeymapInfo = matchedKeyboardLayout.result;
158
+ keymapUpdated = true;
159
+ }
160
+ else if (keymap) {
161
+ if (matchedKeyboardLayout.result.getScore(keymap) > this._activeKeymapInfo.getScore(keymap)) {
162
+ this._activeKeymapInfo = matchedKeyboardLayout.result;
163
+ keymapUpdated = true;
164
+ }
165
+ }
166
+ }
167
+ if (!this._activeKeymapInfo) {
168
+ this._activeKeymapInfo = this.getUSStandardLayout();
169
+ keymapUpdated = true;
170
+ }
171
+ if (!this._activeKeymapInfo || !keymapUpdated) {
172
+ return;
173
+ }
174
+ const index = this._mru.indexOf(this._activeKeymapInfo);
175
+ this._mru.splice(index, 1);
176
+ this._mru.unshift(this._activeKeymapInfo);
177
+ this._setKeyboardData(this._activeKeymapInfo);
178
+ }
179
+ setActiveKeymapInfo(keymapInfo) {
180
+ this._activeKeymapInfo = keymapInfo;
181
+ const index = this._mru.indexOf(this._activeKeymapInfo);
182
+ if (index === 0) {
183
+ return;
184
+ }
185
+ this._mru.splice(index, 1);
186
+ this._mru.unshift(this._activeKeymapInfo);
187
+ this._setKeyboardData(this._activeKeymapInfo);
188
+ }
189
+ setLayoutFromBrowserAPI() {
190
+ this._updateKeyboardLayoutAsync(this._initialized);
191
+ }
192
+ _updateKeyboardLayoutAsync(initialized, keyboardEvent) {
193
+ if (!initialized) {
194
+ return;
195
+ }
196
+ this._getBrowserKeyMapping(keyboardEvent).then(keyMap => {
197
+ if (this.isKeyMappingActive(keyMap)) {
198
+ return;
199
+ }
200
+ this.setActiveKeyMapping(keyMap);
201
+ });
202
+ }
203
+ getKeyboardMapper() {
204
+ const config = readKeyboardConfig(this._configurationService);
205
+ if (config.dispatch === 1 || !this._initialized || !this._activeKeymapInfo) {
206
+ return ( new FallbackKeyboardMapper(config.mapAltGrToCtrlAlt, OS));
207
+ }
208
+ if (!this._keyboardMapper) {
209
+ this._keyboardMapper = ( new CachedKeyboardMapper(
210
+ BrowserKeyboardMapperFactory._createKeyboardMapper(this._activeKeymapInfo, config.mapAltGrToCtrlAlt)
211
+ ));
212
+ }
213
+ return this._keyboardMapper;
214
+ }
215
+ validateCurrentKeyboardMapping(keyboardEvent) {
216
+ if (!this._initialized) {
217
+ return;
218
+ }
219
+ const isCurrentKeyboard = this._validateCurrentKeyboardMapping(keyboardEvent);
220
+ if (isCurrentKeyboard) {
221
+ return;
222
+ }
223
+ this._updateKeyboardLayoutAsync(true, keyboardEvent);
224
+ }
225
+ setKeyboardLayout(layoutName) {
226
+ const matchedLayouts = this.keymapInfos.filter(keymapInfo => getKeyboardLayoutId(keymapInfo.layout) === layoutName);
227
+ if (matchedLayouts.length > 0) {
228
+ this.setActiveKeymapInfo(matchedLayouts[0]);
229
+ }
230
+ }
231
+ _setKeyboardData(keymapInfo) {
232
+ this._initialized = true;
233
+ this._keyboardMapper = null;
234
+ this._onDidChangeKeyboardMapper.fire();
235
+ }
236
+ static _createKeyboardMapper(keymapInfo, mapAltGrToCtrlAlt) {
237
+ const rawMapping = keymapInfo.mapping;
238
+ const isUSStandard = !!keymapInfo.layout.isUSStandard;
239
+ if (OS === 1 ) {
240
+ return ( new WindowsKeyboardMapper(isUSStandard, rawMapping, mapAltGrToCtrlAlt));
241
+ }
242
+ if (( Object.keys(rawMapping)).length === 0) {
243
+ return ( new FallbackKeyboardMapper(mapAltGrToCtrlAlt, OS));
244
+ }
245
+ return ( new MacLinuxKeyboardMapper(isUSStandard, rawMapping, mapAltGrToCtrlAlt, OS));
246
+ }
247
+ _validateCurrentKeyboardMapping(keyboardEvent) {
248
+ if (!this._initialized) {
249
+ return true;
250
+ }
251
+ const standardKeyboardEvent = keyboardEvent;
252
+ const currentKeymap = this._activeKeymapInfo;
253
+ if (!currentKeymap) {
254
+ return true;
255
+ }
256
+ if (standardKeyboardEvent.browserEvent.key === 'Dead' || standardKeyboardEvent.browserEvent.isComposing) {
257
+ return true;
258
+ }
259
+ const mapping = currentKeymap.mapping[standardKeyboardEvent.code];
260
+ if (!mapping) {
261
+ return false;
262
+ }
263
+ if (mapping.value === '') {
264
+ if (keyboardEvent.ctrlKey || keyboardEvent.metaKey) {
265
+ setTimeout(() => {
266
+ this._getBrowserKeyMapping().then((keymap) => {
267
+ if (this.isKeyMappingActive(keymap)) {
268
+ return;
269
+ }
270
+ this.setLayoutFromBrowserAPI();
271
+ });
272
+ }, 350);
273
+ }
274
+ return true;
275
+ }
276
+ const expectedValue = standardKeyboardEvent.altKey && standardKeyboardEvent.shiftKey ? mapping.withShiftAltGr :
277
+ standardKeyboardEvent.altKey ? mapping.withAltGr :
278
+ standardKeyboardEvent.shiftKey ? mapping.withShift : mapping.value;
279
+ const isDead = (standardKeyboardEvent.altKey && standardKeyboardEvent.shiftKey && mapping.withShiftAltGrIsDeadKey) ||
280
+ (standardKeyboardEvent.altKey && mapping.withAltGrIsDeadKey) ||
281
+ (standardKeyboardEvent.shiftKey && mapping.withShiftIsDeadKey) ||
282
+ mapping.valueIsDeadKey;
283
+ if (isDead && standardKeyboardEvent.browserEvent.key !== 'Dead') {
284
+ return false;
285
+ }
286
+ if (!isDead && standardKeyboardEvent.browserEvent.key !== expectedValue) {
287
+ return false;
288
+ }
289
+ return true;
290
+ }
291
+ async _getBrowserKeyMapping(keyboardEvent) {
292
+ if (this.keyboardLayoutMapAllowed) {
293
+ try {
294
+ return await navigator.keyboard.getLayoutMap().then((e) => {
295
+ const ret = {};
296
+ for (const key of e) {
297
+ ret[key[0]] = {
298
+ 'value': key[1],
299
+ 'withShift': '',
300
+ 'withAltGr': '',
301
+ 'withShiftAltGr': ''
302
+ };
303
+ }
304
+ return ret;
305
+ });
306
+ }
307
+ catch {
308
+ this.keyboardLayoutMapAllowed = false;
309
+ }
310
+ }
311
+ if (keyboardEvent && !keyboardEvent.shiftKey && !keyboardEvent.altKey && !keyboardEvent.metaKey && !keyboardEvent.metaKey) {
312
+ const ret = {};
313
+ const standardKeyboardEvent = keyboardEvent;
314
+ ret[standardKeyboardEvent.browserEvent.code] = {
315
+ 'value': standardKeyboardEvent.browserEvent.key,
316
+ 'withShift': '',
317
+ 'withAltGr': '',
318
+ 'withShiftAltGr': ''
319
+ };
320
+ const matchedKeyboardLayout = this.getMatchedKeymapInfo(ret);
321
+ if (matchedKeyboardLayout) {
322
+ return ret;
323
+ }
324
+ return null;
325
+ }
326
+ return null;
327
+ }
328
+ }
329
+ class BrowserKeyboardMapperFactory extends BrowserKeyboardMapperFactoryBase {
330
+ constructor(configurationService, notificationService, storageService, commandService) {
331
+ super(configurationService);
332
+ const platform = isWindows ? 'win' : isMacintosh ? 'darwin' : 'linux';
333
+ __variableDynamicImportRuntime0__('./keyboardLayouts/layout.contribution.' + platform + '.js').then((m) => {
334
+ const keymapInfos = m.KeyboardLayoutContribution.INSTANCE.layoutInfos;
335
+ this._keymapInfos.push(...( keymapInfos.map(info => (( new KeymapInfo(
336
+ info.layout,
337
+ info.secondaryLayouts,
338
+ info.mapping,
339
+ info.isUserKeyboardLayout
340
+ ))))));
341
+ this._mru = this._keymapInfos;
342
+ this._initialized = true;
343
+ this.setLayoutFromBrowserAPI();
344
+ });
345
+ }
346
+ }
347
+ class UserKeyboardLayout extends Disposable {
348
+ get keyboardLayout() { return this._keyboardLayout; }
349
+ constructor(keyboardLayoutResource, fileService) {
350
+ super();
351
+ this.keyboardLayoutResource = keyboardLayoutResource;
352
+ this.fileService = fileService;
353
+ this._onDidChange = this._register(( new Emitter()));
354
+ this.onDidChange = this._onDidChange.event;
355
+ this._keyboardLayout = null;
356
+ this.reloadConfigurationScheduler = this._register(( new RunOnceScheduler(() => this.reload().then(changed => {
357
+ if (changed) {
358
+ this._onDidChange.fire();
359
+ }
360
+ }), 50)));
361
+ this._register(Event.filter(this.fileService.onDidFilesChange, e => e.contains(this.keyboardLayoutResource))(() => this.reloadConfigurationScheduler.schedule()));
362
+ }
363
+ async initialize() {
364
+ await this.reload();
365
+ }
366
+ async reload() {
367
+ const existing = this._keyboardLayout;
368
+ try {
369
+ const content = await this.fileService.readFile(this.keyboardLayoutResource);
370
+ const value = parse(( content.value.toString()));
371
+ if (getNodeType(value) === 'object') {
372
+ const layoutInfo = value.layout;
373
+ const mappings = value.rawMapping;
374
+ this._keyboardLayout = KeymapInfo.createKeyboardLayoutFromDebugInfo(layoutInfo, mappings, true);
375
+ }
376
+ else {
377
+ this._keyboardLayout = null;
378
+ }
379
+ }
380
+ catch (e) {
381
+ this._keyboardLayout = null;
382
+ }
383
+ return existing ? !equals(existing, this._keyboardLayout) : true;
384
+ }
385
+ }
386
+ let BrowserKeyboardLayoutService = class BrowserKeyboardLayoutService extends Disposable {
387
+ constructor(environmentService, fileService, notificationService, storageService, commandService, configurationService) {
388
+ super();
389
+ this.configurationService = configurationService;
390
+ this._onDidChangeKeyboardLayout = ( new Emitter());
391
+ this.onDidChangeKeyboardLayout = this._onDidChangeKeyboardLayout.event;
392
+ const keyboardConfig = configurationService.getValue('keyboard');
393
+ const layout = keyboardConfig.layout;
394
+ this._keyboardLayoutMode = layout ?? 'autodetect';
395
+ this._factory = ( new BrowserKeyboardMapperFactory(configurationService, notificationService, storageService, commandService));
396
+ this._register(this._factory.onDidChangeKeyboardMapper(() => {
397
+ this._onDidChangeKeyboardLayout.fire();
398
+ }));
399
+ if (layout && layout !== 'autodetect') {
400
+ this._factory.setKeyboardLayout(layout);
401
+ }
402
+ this._register(configurationService.onDidChangeConfiguration(e => {
403
+ if (e.affectsConfiguration('keyboard.layout')) {
404
+ const keyboardConfig = configurationService.getValue('keyboard');
405
+ const layout = keyboardConfig.layout;
406
+ this._keyboardLayoutMode = layout;
407
+ if (layout === 'autodetect') {
408
+ this._factory.setLayoutFromBrowserAPI();
409
+ }
410
+ else {
411
+ this._factory.setKeyboardLayout(layout);
412
+ }
413
+ }
414
+ }));
415
+ this._userKeyboardLayout = ( new UserKeyboardLayout(environmentService.keyboardLayoutResource, fileService));
416
+ this._userKeyboardLayout.initialize().then(() => {
417
+ if (this._userKeyboardLayout.keyboardLayout) {
418
+ this._factory.registerKeyboardLayout(this._userKeyboardLayout.keyboardLayout);
419
+ this.setUserKeyboardLayoutIfMatched();
420
+ }
421
+ });
422
+ this._register(this._userKeyboardLayout.onDidChange(() => {
423
+ const userKeyboardLayouts = this._factory.keymapInfos.filter(layout => layout.isUserKeyboardLayout);
424
+ if (userKeyboardLayouts.length) {
425
+ if (this._userKeyboardLayout.keyboardLayout) {
426
+ userKeyboardLayouts[0].update(this._userKeyboardLayout.keyboardLayout);
427
+ }
428
+ else {
429
+ this._factory.removeKeyboardLayout(userKeyboardLayouts[0]);
430
+ }
431
+ }
432
+ else {
433
+ if (this._userKeyboardLayout.keyboardLayout) {
434
+ this._factory.registerKeyboardLayout(this._userKeyboardLayout.keyboardLayout);
435
+ }
436
+ }
437
+ this.setUserKeyboardLayoutIfMatched();
438
+ }));
439
+ }
440
+ setUserKeyboardLayoutIfMatched() {
441
+ const keyboardConfig = this.configurationService.getValue('keyboard');
442
+ const layout = keyboardConfig.layout;
443
+ if (layout && this._userKeyboardLayout.keyboardLayout) {
444
+ if (getKeyboardLayoutId(this._userKeyboardLayout.keyboardLayout.layout) === layout && this._factory.activeKeymap) {
445
+ if (!this._userKeyboardLayout.keyboardLayout.equal(this._factory.activeKeymap)) {
446
+ this._factory.setActiveKeymapInfo(this._userKeyboardLayout.keyboardLayout);
447
+ }
448
+ }
449
+ }
450
+ }
451
+ getKeyboardMapper() {
452
+ return this._factory.getKeyboardMapper();
453
+ }
454
+ getCurrentKeyboardLayout() {
455
+ return this._factory.activeKeyboardLayout;
456
+ }
457
+ getAllKeyboardLayouts() {
458
+ return this._factory.keyboardLayouts;
459
+ }
460
+ getRawKeyboardMapping() {
461
+ return this._factory.activeKeyMapping;
462
+ }
463
+ validateCurrentKeyboardMapping(keyboardEvent) {
464
+ if (this._keyboardLayoutMode !== 'autodetect') {
465
+ return;
466
+ }
467
+ this._factory.validateCurrentKeyboardMapping(keyboardEvent);
468
+ }
469
+ };
470
+ BrowserKeyboardLayoutService = ( __decorate([
471
+ ( __param(0, IEnvironmentService)),
472
+ ( __param(1, IFileService)),
473
+ ( __param(2, INotificationService)),
474
+ ( __param(3, IStorageService)),
475
+ ( __param(4, ICommandService)),
476
+ ( __param(5, IConfigurationService))
477
+ ], BrowserKeyboardLayoutService));
478
+ const configurationRegistry = ( Registry.as(Extensions.Configuration));
479
+ const keyboardConfiguration = {
480
+ 'id': 'keyboard',
481
+ 'order': 15,
482
+ 'type': 'object',
483
+ 'title': ( localizeWithPath(
484
+ 'vs/workbench/services/keybinding/browser/keyboardLayoutService',
485
+ 'keyboardConfigurationTitle',
486
+ "Keyboard"
487
+ )),
488
+ 'properties': {
489
+ 'keyboard.layout': {
490
+ 'type': 'string',
491
+ 'default': 'autodetect',
492
+ 'description': ( localizeWithPath(
493
+ 'vs/workbench/services/keybinding/browser/keyboardLayoutService',
494
+ 'keyboard.layout.config',
495
+ "Control the keyboard layout used in web."
496
+ ))
497
+ }
498
+ }
499
+ };
500
+ configurationRegistry.registerConfiguration(keyboardConfiguration);
501
+
502
+ export { BrowserKeyboardLayoutService, BrowserKeyboardMapperFactory, BrowserKeyboardMapperFactoryBase };
@@ -0,0 +1,14 @@
1
+ class KeyboardLayoutContribution {
2
+ static { this.INSTANCE = ( new KeyboardLayoutContribution()); }
3
+ get layoutInfos() {
4
+ return this._layoutInfos;
5
+ }
6
+ constructor() {
7
+ this._layoutInfos = [];
8
+ }
9
+ registerKeyboardLayout(layout) {
10
+ this._layoutInfos.push(layout);
11
+ }
12
+ }
13
+
14
+ export { KeyboardLayoutContribution };
@@ -0,0 +1,163 @@
1
+ import { KeyboardLayoutContribution } from './_.contribution.js';
2
+
3
+ KeyboardLayoutContribution.INSTANCE.registerKeyboardLayout({
4
+ layout: { name: '00000405', id: '', text: 'Czech' },
5
+ secondaryLayouts: [],
6
+ mapping: {
7
+ Sleep: [],
8
+ WakeUp: [],
9
+ KeyA: ['a', 'A', '', '', 0, 'VK_A'],
10
+ KeyB: ['b', 'B', '{', '', 0, 'VK_B'],
11
+ KeyC: ['c', 'C', '&', '', 0, 'VK_C'],
12
+ KeyD: ['d', 'D', 'Đ', '', 0, 'VK_D'],
13
+ KeyE: ['e', 'E', '€', '', 0, 'VK_E'],
14
+ KeyF: ['f', 'F', '[', '', 0, 'VK_F'],
15
+ KeyG: ['g', 'G', ']', '', 0, 'VK_G'],
16
+ KeyH: ['h', 'H', '', '', 0, 'VK_H'],
17
+ KeyI: ['i', 'I', '', '', 0, 'VK_I'],
18
+ KeyJ: ['j', 'J', '', '', 0, 'VK_J'],
19
+ KeyK: ['k', 'K', 'ł', '', 0, 'VK_K'],
20
+ KeyL: ['l', 'L', 'Ł', '', 0, 'VK_L'],
21
+ KeyM: ['m', 'M', '', '', 0, 'VK_M'],
22
+ KeyN: ['n', 'N', '}', '', 0, 'VK_N'],
23
+ KeyO: ['o', 'O', '', '', 0, 'VK_O'],
24
+ KeyP: ['p', 'P', '', '', 0, 'VK_P'],
25
+ KeyQ: ['q', 'Q', '\\', '', 0, 'VK_Q'],
26
+ KeyR: ['r', 'R', '', '', 0, 'VK_R'],
27
+ KeyS: ['s', 'S', 'đ', '', 0, 'VK_S'],
28
+ KeyT: ['t', 'T', '', '', 0, 'VK_T'],
29
+ KeyU: ['u', 'U', '', '', 0, 'VK_U'],
30
+ KeyV: ['v', 'V', '@', '', 0, 'VK_V'],
31
+ KeyW: ['w', 'W', '|', '', 0, 'VK_W'],
32
+ KeyX: ['x', 'X', '#', '', 0, 'VK_X'],
33
+ KeyY: ['z', 'Z', '', '', 0, 'VK_Z'],
34
+ KeyZ: ['y', 'Y', '', '', 0, 'VK_Y'],
35
+ Digit1: ['+', '1', '~', '', 0, 'VK_1'],
36
+ Digit2: ['ě', '2', 'ˇ', '', 0, 'VK_2'],
37
+ Digit3: ['š', '3', '^', '', 0, 'VK_3'],
38
+ Digit4: ['č', '4', '˘', '', 0, 'VK_4'],
39
+ Digit5: ['ř', '5', '°', '', 0, 'VK_5'],
40
+ Digit6: ['ž', '6', '˛', '', 0, 'VK_6'],
41
+ Digit7: ['ý', '7', '`', '', 0, 'VK_7'],
42
+ Digit8: ['á', '8', '˙', '', 0, 'VK_8'],
43
+ Digit9: ['í', '9', '´', '', 0, 'VK_9'],
44
+ Digit0: ['é', '0', '˝', '', 0, 'VK_0'],
45
+ Enter: [],
46
+ Escape: [],
47
+ Backspace: [],
48
+ Tab: [],
49
+ Space: [' ', ' ', '', '', 0, 'VK_SPACE'],
50
+ Minus: ['=', '%', '¨', '', 0, 'VK_OEM_PLUS'],
51
+ Equal: ['´', 'ˇ', '¸', '', 0, 'VK_OEM_2'],
52
+ BracketLeft: ['ú', '/', '÷', '', 0, 'VK_OEM_4'],
53
+ BracketRight: [')', '(', '×', '', 0, 'VK_OEM_6'],
54
+ Backslash: ['¨', '\'', '¤', '', 0, 'VK_OEM_5'],
55
+ Semicolon: ['ů', '"', '$', '', 0, 'VK_OEM_1'],
56
+ Quote: ['§', '!', 'ß', '', 0, 'VK_OEM_7'],
57
+ Backquote: [';', '°', '', '', 0, 'VK_OEM_3'],
58
+ Comma: [',', '?', '<', '', 0, 'VK_OEM_COMMA'],
59
+ Period: ['.', ':', '>', '', 0, 'VK_OEM_PERIOD'],
60
+ Slash: ['-', '_', '*', '', 0, 'VK_OEM_MINUS'],
61
+ CapsLock: [],
62
+ F1: [],
63
+ F2: [],
64
+ F3: [],
65
+ F4: [],
66
+ F5: [],
67
+ F6: [],
68
+ F7: [],
69
+ F8: [],
70
+ F9: [],
71
+ F10: [],
72
+ F11: [],
73
+ F12: [],
74
+ PrintScreen: [],
75
+ ScrollLock: [],
76
+ Pause: [],
77
+ Insert: [],
78
+ Home: [],
79
+ PageUp: [],
80
+ Delete: [],
81
+ End: [],
82
+ PageDown: [],
83
+ ArrowRight: [],
84
+ ArrowLeft: [],
85
+ ArrowDown: [],
86
+ ArrowUp: [],
87
+ NumLock: [],
88
+ NumpadDivide: ['/', '/', '', '', 0, 'VK_DIVIDE'],
89
+ NumpadMultiply: ['*', '*', '', '', 0, 'VK_MULTIPLY'],
90
+ NumpadSubtract: ['-', '-', '', '', 0, 'VK_SUBTRACT'],
91
+ NumpadAdd: ['+', '+', '', '', 0, 'VK_ADD'],
92
+ NumpadEnter: [],
93
+ Numpad1: [],
94
+ Numpad2: [],
95
+ Numpad3: [],
96
+ Numpad4: [],
97
+ Numpad5: [],
98
+ Numpad6: [],
99
+ Numpad7: [],
100
+ Numpad8: [],
101
+ Numpad9: [],
102
+ Numpad0: [],
103
+ NumpadDecimal: [],
104
+ IntlBackslash: ['\\', '|', '', '', 0, 'VK_OEM_102'],
105
+ ContextMenu: [],
106
+ Power: [],
107
+ NumpadEqual: [],
108
+ F13: [],
109
+ F14: [],
110
+ F15: [],
111
+ F16: [],
112
+ F17: [],
113
+ F18: [],
114
+ F19: [],
115
+ F20: [],
116
+ F21: [],
117
+ F22: [],
118
+ F23: [],
119
+ F24: [],
120
+ Help: [],
121
+ Undo: [],
122
+ Cut: [],
123
+ Copy: [],
124
+ Paste: [],
125
+ AudioVolumeMute: [],
126
+ AudioVolumeUp: [],
127
+ AudioVolumeDown: [],
128
+ NumpadComma: [],
129
+ IntlRo: [],
130
+ KanaMode: [],
131
+ IntlYen: [],
132
+ Convert: [],
133
+ NonConvert: [],
134
+ Lang1: [],
135
+ Lang2: [],
136
+ Lang3: [],
137
+ Lang4: [],
138
+ ControlLeft: [],
139
+ ShiftLeft: [],
140
+ AltLeft: [],
141
+ MetaLeft: [],
142
+ ControlRight: [],
143
+ ShiftRight: [],
144
+ AltRight: [],
145
+ MetaRight: [],
146
+ MediaTrackNext: [],
147
+ MediaTrackPrevious: [],
148
+ MediaStop: [],
149
+ Eject: [],
150
+ MediaPlayPause: [],
151
+ MediaSelect: [],
152
+ LaunchMail: [],
153
+ LaunchApp2: [],
154
+ LaunchApp1: [],
155
+ BrowserSearch: [],
156
+ BrowserHome: [],
157
+ BrowserBack: [],
158
+ BrowserForward: [],
159
+ BrowserStop: [],
160
+ BrowserRefresh: [],
161
+ BrowserFavorites: []
162
+ }
163
+ });