@codingame/monaco-vscode-keybindings-service-override 2.1.3 → 2.2.0-next.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.
- package/keybindings.js +4 -3
- package/package.json +9 -3
- package/vscode/src/vs/workbench/services/keybinding/browser/keybindingService.js +1 -1
- package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayoutService.js +4 -2
- package/vscode/src/vs/workbench/services/keybinding/common/keybindingIO.js +1 -1
- package/vscode/src/vs/base/common/keybindingParser.js +0 -89
package/keybindings.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { __decorate, __param } from './external/tslib/tslib.es6.js';
|
|
2
|
-
import { StandaloneServices } from 'vscode/vscode/vs/editor/standalone/browser/standaloneServices';
|
|
3
2
|
import { SyncDescriptor } from 'vscode/vscode/vs/platform/instantiation/common/descriptors';
|
|
4
3
|
import { WorkbenchKeybindingService } from './vscode/src/vs/workbench/services/keybinding/browser/keybindingService.js';
|
|
5
4
|
import { IKeybindingService } from 'vscode/vscode/vs/platform/keybinding/common/keybinding';
|
|
@@ -28,14 +27,16 @@ import { onRenderWorkbench } from 'vscode/lifecycle';
|
|
|
28
27
|
import 'vscode/vscode/vs/workbench/browser/workbench.contribution';
|
|
29
28
|
import './vscode/src/vs/workbench/contrib/keybindings/browser/keybindings.contribution.js';
|
|
30
29
|
import './vscode/src/vs/workbench/contrib/commands/common/commands.contribution.js';
|
|
30
|
+
import { getService } from 'vscode/services';
|
|
31
31
|
|
|
32
32
|
const defaultUserKeybindindsFile = ( URI.from({ scheme: Schemas.vscodeUserData, path: '/User/keybindings.json' }));
|
|
33
33
|
async function initUserKeybindings(configurationJson, options, file = defaultUserKeybindindsFile) {
|
|
34
34
|
await initFile(file, configurationJson, options);
|
|
35
35
|
}
|
|
36
36
|
async function updateUserKeybindings(keybindingsJson) {
|
|
37
|
-
const userDataProfilesService =
|
|
38
|
-
await
|
|
37
|
+
const userDataProfilesService = await getService(IUserDataProfilesService);
|
|
38
|
+
const fileService = await getService(IFileService);
|
|
39
|
+
await fileService.writeFile(userDataProfilesService.defaultProfile.keybindingsResource, VSBuffer.fromString(keybindingsJson));
|
|
39
40
|
}
|
|
40
41
|
let DynamicWorkbenchKeybindingService = class DynamicWorkbenchKeybindingService extends WorkbenchKeybindingService {
|
|
41
42
|
constructor(shouldUseGlobalKeybindings, contextKeyService, commandService, telemetryService, notificationService, userDataProfileService, hostService, extensionService, fileService, uriIdentityService, logService, keyboardLayoutService) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codingame/monaco-vscode-keybindings-service-override",
|
|
3
|
-
"version": "2.1
|
|
3
|
+
"version": "2.2.0-next.1",
|
|
4
4
|
"keywords": [],
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "CodinGame",
|
|
@@ -18,8 +18,14 @@
|
|
|
18
18
|
"module": "index.js",
|
|
19
19
|
"types": "index.d.ts",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"vscode": "npm:@codingame/monaco-vscode-api@2.1
|
|
21
|
+
"vscode": "npm:@codingame/monaco-vscode-api@2.2.0-next.1",
|
|
22
22
|
"vscode-marked": "npm:marked@=3.0.2",
|
|
23
|
-
"@codingame/monaco-vscode-files-service-override": "2.1
|
|
23
|
+
"@codingame/monaco-vscode-files-service-override": "2.2.0-next.1",
|
|
24
|
+
"@codingame/monaco-vscode-quickaccess-service-override": "2.2.0-next.1",
|
|
25
|
+
"@codingame/monaco-vscode-extensions-service-override": "2.2.0-next.1",
|
|
26
|
+
"@codingame/monaco-vscode-environment-service-override": "2.2.0-next.1",
|
|
27
|
+
"@codingame/monaco-vscode-layout-service-override": "2.2.0-next.1",
|
|
28
|
+
"@codingame/monaco-vscode-host-service-override": "2.2.0-next.1",
|
|
29
|
+
"@codingame/monaco-vscode-base-service-override": "2.2.0-next.1"
|
|
24
30
|
}
|
|
25
31
|
}
|
|
@@ -8,7 +8,7 @@ import { DeferredPromise, RunOnceScheduler } from 'vscode/vscode/vs/base/common/
|
|
|
8
8
|
import { Event, Emitter } from 'vscode/vscode/vs/base/common/event';
|
|
9
9
|
import { parse } from 'vscode/vscode/vs/base/common/json';
|
|
10
10
|
import { UserSettingsLabelProvider } from 'vscode/vscode/vs/base/common/keybindingLabels';
|
|
11
|
-
import { KeybindingParser } from '
|
|
11
|
+
import { KeybindingParser } from 'vscode/vscode/vs/base/common/keybindingParser';
|
|
12
12
|
import { KeyCodeChord, ScanCodeChord } from 'vscode/vscode/vs/base/common/keybindings';
|
|
13
13
|
import { KeyCodeUtils, ScanCodeUtils, IMMUTABLE_CODE_TO_KEY_CODE } from 'vscode/vscode/vs/base/common/keyCodes';
|
|
14
14
|
import { DisposableStore, Disposable } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
@@ -61,6 +61,7 @@ class BrowserKeyboardMapperFactoryBase extends Disposable {
|
|
|
61
61
|
this._configurationService = _configurationService;
|
|
62
62
|
this._onDidChangeKeyboardMapper = ( new Emitter());
|
|
63
63
|
this.onDidChangeKeyboardMapper = this._onDidChangeKeyboardMapper.event;
|
|
64
|
+
this.keyboardLayoutMapAllowed = navigator.keyboard !== undefined;
|
|
64
65
|
this._keyboardMapper = null;
|
|
65
66
|
this._initialized = false;
|
|
66
67
|
this._keymapInfos = [];
|
|
@@ -288,7 +289,7 @@ class BrowserKeyboardMapperFactoryBase extends Disposable {
|
|
|
288
289
|
return true;
|
|
289
290
|
}
|
|
290
291
|
async _getBrowserKeyMapping(keyboardEvent) {
|
|
291
|
-
if (
|
|
292
|
+
if (this.keyboardLayoutMapAllowed) {
|
|
292
293
|
try {
|
|
293
294
|
return await navigator.keyboard.getLayoutMap().then((e) => {
|
|
294
295
|
const ret = {};
|
|
@@ -304,9 +305,10 @@ class BrowserKeyboardMapperFactoryBase extends Disposable {
|
|
|
304
305
|
});
|
|
305
306
|
}
|
|
306
307
|
catch {
|
|
308
|
+
this.keyboardLayoutMapAllowed = false;
|
|
307
309
|
}
|
|
308
310
|
}
|
|
309
|
-
|
|
311
|
+
if (keyboardEvent && !keyboardEvent.shiftKey && !keyboardEvent.altKey && !keyboardEvent.metaKey && !keyboardEvent.metaKey) {
|
|
310
312
|
const ret = {};
|
|
311
313
|
const standardKeyboardEvent = keyboardEvent;
|
|
312
314
|
ret[standardKeyboardEvent.browserEvent.code] = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { KeybindingParser } from '
|
|
1
|
+
import { KeybindingParser } from 'vscode/vscode/vs/base/common/keybindingParser';
|
|
2
2
|
import { ContextKeyExpr } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
|
|
3
3
|
|
|
4
4
|
class KeybindingIO {
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { ScanCodeUtils, KeyCodeUtils } from 'vscode/vscode/vs/base/common/keyCodes';
|
|
2
|
-
import { ScanCodeChord, KeyCodeChord, Keybinding } from 'vscode/vscode/vs/base/common/keybindings';
|
|
3
|
-
|
|
4
|
-
class KeybindingParser {
|
|
5
|
-
static _readModifiers(input) {
|
|
6
|
-
input = input.toLowerCase().trim();
|
|
7
|
-
let ctrl = false;
|
|
8
|
-
let shift = false;
|
|
9
|
-
let alt = false;
|
|
10
|
-
let meta = false;
|
|
11
|
-
let matchedModifier;
|
|
12
|
-
do {
|
|
13
|
-
matchedModifier = false;
|
|
14
|
-
if (/^ctrl(\+|\-)/.test(input)) {
|
|
15
|
-
ctrl = true;
|
|
16
|
-
input = input.substr('ctrl-'.length);
|
|
17
|
-
matchedModifier = true;
|
|
18
|
-
}
|
|
19
|
-
if (/^shift(\+|\-)/.test(input)) {
|
|
20
|
-
shift = true;
|
|
21
|
-
input = input.substr('shift-'.length);
|
|
22
|
-
matchedModifier = true;
|
|
23
|
-
}
|
|
24
|
-
if (/^alt(\+|\-)/.test(input)) {
|
|
25
|
-
alt = true;
|
|
26
|
-
input = input.substr('alt-'.length);
|
|
27
|
-
matchedModifier = true;
|
|
28
|
-
}
|
|
29
|
-
if (/^meta(\+|\-)/.test(input)) {
|
|
30
|
-
meta = true;
|
|
31
|
-
input = input.substr('meta-'.length);
|
|
32
|
-
matchedModifier = true;
|
|
33
|
-
}
|
|
34
|
-
if (/^win(\+|\-)/.test(input)) {
|
|
35
|
-
meta = true;
|
|
36
|
-
input = input.substr('win-'.length);
|
|
37
|
-
matchedModifier = true;
|
|
38
|
-
}
|
|
39
|
-
if (/^cmd(\+|\-)/.test(input)) {
|
|
40
|
-
meta = true;
|
|
41
|
-
input = input.substr('cmd-'.length);
|
|
42
|
-
matchedModifier = true;
|
|
43
|
-
}
|
|
44
|
-
} while (matchedModifier);
|
|
45
|
-
let key;
|
|
46
|
-
const firstSpaceIdx = input.indexOf(' ');
|
|
47
|
-
if (firstSpaceIdx > 0) {
|
|
48
|
-
key = input.substring(0, firstSpaceIdx);
|
|
49
|
-
input = input.substring(firstSpaceIdx);
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
key = input;
|
|
53
|
-
input = '';
|
|
54
|
-
}
|
|
55
|
-
return {
|
|
56
|
-
remains: input,
|
|
57
|
-
ctrl,
|
|
58
|
-
shift,
|
|
59
|
-
alt,
|
|
60
|
-
meta,
|
|
61
|
-
key
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
static parseChord(input) {
|
|
65
|
-
const mods = this._readModifiers(input);
|
|
66
|
-
const scanCodeMatch = mods.key.match(/^\[([^\]]+)\]$/);
|
|
67
|
-
if (scanCodeMatch) {
|
|
68
|
-
const strScanCode = scanCodeMatch[1];
|
|
69
|
-
const scanCode = ScanCodeUtils.lowerCaseToEnum(strScanCode);
|
|
70
|
-
return [( new ScanCodeChord(mods.ctrl, mods.shift, mods.alt, mods.meta, scanCode)), mods.remains];
|
|
71
|
-
}
|
|
72
|
-
const keyCode = KeyCodeUtils.fromUserSettings(mods.key);
|
|
73
|
-
return [( new KeyCodeChord(mods.ctrl, mods.shift, mods.alt, mods.meta, keyCode)), mods.remains];
|
|
74
|
-
}
|
|
75
|
-
static parseKeybinding(input) {
|
|
76
|
-
if (!input) {
|
|
77
|
-
return null;
|
|
78
|
-
}
|
|
79
|
-
const chords = [];
|
|
80
|
-
let chord;
|
|
81
|
-
while (input.length > 0) {
|
|
82
|
-
[chord, input] = this.parseChord(input);
|
|
83
|
-
chords.push(chord);
|
|
84
|
-
}
|
|
85
|
-
return (chords.length > 0 ? ( new Keybinding(chords)) : null);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export { KeybindingParser };
|