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