1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
18 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
19 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
20 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
21 | return c > 3 && r && Object.defineProperty(target, key, r), r;
|
22 | };
|
23 | var __metadata = (this && this.__metadata) || function (k, v) {
|
24 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
25 | };
|
26 | var KeybindingRegistry_1;
|
27 | Object.defineProperty(exports, "__esModule", { value: true });
|
28 | exports.KeybindingRegistry = exports.KeybindingContexts = exports.KeybindingContext = exports.KeybindingContribution = exports.Keybinding = exports.KeybindingScope = void 0;
|
29 | const inversify_1 = require("inversify");
|
30 | const os_1 = require("../common/os");
|
31 | const event_1 = require("../common/event");
|
32 | const command_1 = require("../common/command");
|
33 | const disposable_1 = require("../common/disposable");
|
34 | const keys_1 = require("./keyboard/keys");
|
35 | const keyboard_layout_service_1 = require("./keyboard/keyboard-layout-service");
|
36 | const contribution_provider_1 = require("../common/contribution-provider");
|
37 | const logger_1 = require("../common/logger");
|
38 | const status_bar_1 = require("./status-bar/status-bar");
|
39 | const context_key_service_1 = require("./context-key-service");
|
40 | const core_preferences_1 = require("./core-preferences");
|
41 | const common = require("../common/keybinding");
|
42 | const nls_1 = require("../common/nls");
|
43 | var KeybindingScope;
|
44 | (function (KeybindingScope) {
|
45 | KeybindingScope[KeybindingScope["DEFAULT"] = 0] = "DEFAULT";
|
46 | KeybindingScope[KeybindingScope["USER"] = 1] = "USER";
|
47 | KeybindingScope[KeybindingScope["WORKSPACE"] = 2] = "WORKSPACE";
|
48 | KeybindingScope[KeybindingScope["END"] = 3] = "END";
|
49 | })(KeybindingScope = exports.KeybindingScope || (exports.KeybindingScope = {}));
|
50 | (function (KeybindingScope) {
|
51 | KeybindingScope.length = KeybindingScope.END - KeybindingScope.DEFAULT;
|
52 | })(KeybindingScope = exports.KeybindingScope || (exports.KeybindingScope = {}));
|
53 | exports.Keybinding = common.Keybinding;
|
54 | exports.KeybindingContribution = Symbol('KeybindingContribution');
|
55 | exports.KeybindingContext = Symbol('KeybindingContext');
|
56 | var KeybindingContexts;
|
57 | (function (KeybindingContexts) {
|
58 | KeybindingContexts.NOOP_CONTEXT = {
|
59 | id: 'noop.keybinding.context',
|
60 | isEnabled: () => true
|
61 | };
|
62 | KeybindingContexts.DEFAULT_CONTEXT = {
|
63 | id: 'default.keybinding.context',
|
64 | isEnabled: () => false
|
65 | };
|
66 | })(KeybindingContexts = exports.KeybindingContexts || (exports.KeybindingContexts = {}));
|
67 | let KeybindingRegistry = KeybindingRegistry_1 = class KeybindingRegistry {
|
68 | constructor() {
|
69 | this.keySequence = [];
|
70 | this.contexts = {};
|
71 | this.keymaps = [...Array(KeybindingScope.length)].map(() => []);
|
72 | this.keybindingsChanged = new event_1.Emitter();
|
73 | this.toResetKeymap = new Map();
|
74 | }
|
75 | async onStart() {
|
76 | await this.keyboardLayoutService.initialize();
|
77 | this.keyboardLayoutService.onKeyboardLayoutChanged(newLayout => {
|
78 | this.clearResolvedKeybindings();
|
79 | this.keybindingsChanged.fire(undefined);
|
80 | });
|
81 | this.registerContext(KeybindingContexts.NOOP_CONTEXT);
|
82 | this.registerContext(KeybindingContexts.DEFAULT_CONTEXT);
|
83 | this.registerContext(...this.contextProvider.getContributions());
|
84 | for (const contribution of this.contributions.getContributions()) {
|
85 | contribution.registerKeybindings(this);
|
86 | }
|
87 | }
|
88 | |
89 |
|
90 |
|
91 |
|
92 | get onKeybindingsChanged() {
|
93 | return this.keybindingsChanged.event;
|
94 | }
|
95 | |
96 |
|
97 |
|
98 |
|
99 |
|
100 |
|
101 | registerContext(...contexts) {
|
102 | for (const context of contexts) {
|
103 | const { id } = context;
|
104 | if (this.contexts[id]) {
|
105 | this.logger.error(`A keybinding context with ID ${id} is already registered.`);
|
106 | }
|
107 | else {
|
108 | this.contexts[id] = context;
|
109 | }
|
110 | }
|
111 | }
|
112 | |
113 |
|
114 |
|
115 |
|
116 |
|
117 |
|
118 |
|
119 | registerKeybinding(binding) {
|
120 | return this.doRegisterKeybinding(binding);
|
121 | }
|
122 | |
123 |
|
124 |
|
125 |
|
126 |
|
127 | registerKeybindings(...bindings) {
|
128 | return this.doRegisterKeybindings(bindings, KeybindingScope.DEFAULT);
|
129 | }
|
130 | unregisterKeybinding(arg) {
|
131 | const keymap = this.keymaps[KeybindingScope.DEFAULT];
|
132 | const filter = command_1.Command.is(arg)
|
133 | ? ({ command }) => command === arg.id
|
134 | : ({ keybinding }) => exports.Keybinding.is(arg)
|
135 | ? keybinding === arg.keybinding
|
136 | : keybinding === arg;
|
137 | for (const binding of keymap.filter(filter)) {
|
138 | const idx = keymap.indexOf(binding);
|
139 | if (idx !== -1) {
|
140 | keymap.splice(idx, 1);
|
141 | }
|
142 | }
|
143 | }
|
144 | doRegisterKeybindings(bindings, scope = KeybindingScope.DEFAULT) {
|
145 | const toDispose = new disposable_1.DisposableCollection();
|
146 | for (const binding of bindings) {
|
147 | toDispose.push(this.doRegisterKeybinding(binding, scope));
|
148 | }
|
149 | return toDispose;
|
150 | }
|
151 | doRegisterKeybinding(binding, scope = KeybindingScope.DEFAULT) {
|
152 | try {
|
153 | this.resolveKeybinding(binding);
|
154 | const scoped = Object.assign(binding, { scope });
|
155 | this.insertBindingIntoScope(scoped, scope);
|
156 | return disposable_1.Disposable.create(() => {
|
157 | const index = this.keymaps[scope].indexOf(scoped);
|
158 | if (index !== -1) {
|
159 | this.keymaps[scope].splice(index, 1);
|
160 | }
|
161 | });
|
162 | }
|
163 | catch (error) {
|
164 | this.logger.warn(`Could not register keybinding:\n ${common.Keybinding.stringify(binding)}\n${error}`);
|
165 | return disposable_1.Disposable.NULL;
|
166 | }
|
167 | }
|
168 | |
169 |
|
170 |
|
171 |
|
172 | insertBindingIntoScope(item, scope) {
|
173 | const scopedKeymap = this.keymaps[scope];
|
174 | const getNumberOfKeystrokes = (binding) => { var _a, _b; return ((_b = (_a = binding.keybinding.trim().match(/\s/g)) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) + 1; };
|
175 | const numberOfKeystrokesInBinding = getNumberOfKeystrokes(item);
|
176 | const indexOfFirstItemWithEqualStrokes = scopedKeymap.findIndex(existingBinding => getNumberOfKeystrokes(existingBinding) === numberOfKeystrokesInBinding);
|
177 | if (indexOfFirstItemWithEqualStrokes > -1) {
|
178 | scopedKeymap.splice(indexOfFirstItemWithEqualStrokes, 0, item);
|
179 | }
|
180 | else {
|
181 | scopedKeymap.push(item);
|
182 | }
|
183 | }
|
184 | |
185 |
|
186 |
|
187 | resolveKeybinding(binding) {
|
188 | if (!binding.resolved) {
|
189 | const sequence = keys_1.KeySequence.parse(binding.keybinding);
|
190 | binding.resolved = sequence.map(code => this.keyboardLayoutService.resolveKeyCode(code));
|
191 | }
|
192 | return binding.resolved;
|
193 | }
|
194 | |
195 |
|
196 |
|
197 |
|
198 | clearResolvedKeybindings() {
|
199 | for (let i = KeybindingScope.DEFAULT; i < KeybindingScope.END; i++) {
|
200 | const bindings = this.keymaps[i];
|
201 | for (let j = 0; j < bindings.length; j++) {
|
202 | const binding = bindings[j];
|
203 | binding.resolved = undefined;
|
204 | }
|
205 | }
|
206 | }
|
207 | |
208 |
|
209 |
|
210 |
|
211 |
|
212 |
|
213 | containsKeybindingInScope(binding, scope = KeybindingScope.USER) {
|
214 | const bindingKeySequence = this.resolveKeybinding(binding);
|
215 | const collisions = this.getKeySequenceCollisions(this.getUsableBindings(this.keymaps[scope]), bindingKeySequence)
|
216 | .filter(b => b.context === binding.context && !b.when && !binding.when);
|
217 | if (collisions.full.length > 0) {
|
218 | return true;
|
219 | }
|
220 | if (collisions.partial.length > 0) {
|
221 | return true;
|
222 | }
|
223 | if (collisions.shadow.length > 0) {
|
224 | return true;
|
225 | }
|
226 | return false;
|
227 | }
|
228 | |
229 |
|
230 |
|
231 |
|
232 |
|
233 |
|
234 | acceleratorFor(keybinding, separator = ' ', asciiOnly = false) {
|
235 | const bindingKeySequence = this.resolveKeybinding(keybinding);
|
236 | return this.acceleratorForSequence(bindingKeySequence, separator, asciiOnly);
|
237 | }
|
238 | |
239 |
|
240 |
|
241 |
|
242 |
|
243 |
|
244 | acceleratorForSequence(keySequence, separator = ' ', asciiOnly = false) {
|
245 | return keySequence.map(keyCode => this.acceleratorForKeyCode(keyCode, separator, asciiOnly));
|
246 | }
|
247 | |
248 |
|
249 |
|
250 |
|
251 |
|
252 |
|
253 |
|
254 | acceleratorForKeyCode(keyCode, separator = ' ', asciiOnly = false) {
|
255 | return this.componentsForKeyCode(keyCode, asciiOnly).join(separator);
|
256 | }
|
257 | componentsForKeyCode(keyCode, asciiOnly = false) {
|
258 | const keyCodeResult = [];
|
259 | const useSymbols = os_1.isOSX && !asciiOnly;
|
260 | if (keyCode.meta && os_1.isOSX) {
|
261 | keyCodeResult.push(useSymbols ? '⌘' : 'Cmd');
|
262 | }
|
263 | if (keyCode.ctrl) {
|
264 | keyCodeResult.push(useSymbols ? '⌃' : 'Ctrl');
|
265 | }
|
266 | if (keyCode.alt) {
|
267 | keyCodeResult.push(useSymbols ? '⌥' : 'Alt');
|
268 | }
|
269 | if (keyCode.shift) {
|
270 | keyCodeResult.push(useSymbols ? '⇧' : 'Shift');
|
271 | }
|
272 | if (keyCode.key) {
|
273 | keyCodeResult.push(this.acceleratorForKey(keyCode.key, asciiOnly));
|
274 | }
|
275 | return keyCodeResult;
|
276 | }
|
277 | |
278 |
|
279 |
|
280 |
|
281 |
|
282 | acceleratorForKey(key, asciiOnly = false) {
|
283 | if (os_1.isOSX && !asciiOnly) {
|
284 | if (key === keys_1.Key.ARROW_LEFT) {
|
285 | return '←';
|
286 | }
|
287 | if (key === keys_1.Key.ARROW_RIGHT) {
|
288 | return '→';
|
289 | }
|
290 | if (key === keys_1.Key.ARROW_UP) {
|
291 | return '↑';
|
292 | }
|
293 | if (key === keys_1.Key.ARROW_DOWN) {
|
294 | return '↓';
|
295 | }
|
296 | }
|
297 | const keyString = this.keyboardLayoutService.getKeyboardCharacter(key);
|
298 | if (key.keyCode >= keys_1.Key.KEY_A.keyCode && key.keyCode <= keys_1.Key.KEY_Z.keyCode ||
|
299 | key.keyCode >= keys_1.Key.F1.keyCode && key.keyCode <= keys_1.Key.F24.keyCode) {
|
300 | return keyString.toUpperCase();
|
301 | }
|
302 | else if (keyString.length > 1) {
|
303 | return keyString.charAt(0).toUpperCase() + keyString.slice(1);
|
304 | }
|
305 | else {
|
306 | return keyString;
|
307 | }
|
308 | }
|
309 | |
310 |
|
311 |
|
312 |
|
313 |
|
314 |
|
315 | getKeySequenceCollisions(bindings, candidate) {
|
316 | const result = new KeybindingRegistry_1.KeybindingsResult();
|
317 | for (const binding of bindings) {
|
318 | try {
|
319 | const bindingKeySequence = this.resolveKeybinding(binding);
|
320 | const compareResult = keys_1.KeySequence.compare(candidate, bindingKeySequence);
|
321 | switch (compareResult) {
|
322 | case keys_1.KeySequence.CompareResult.FULL: {
|
323 | result.full.push(binding);
|
324 | break;
|
325 | }
|
326 | case keys_1.KeySequence.CompareResult.PARTIAL: {
|
327 | result.partial.push(binding);
|
328 | break;
|
329 | }
|
330 | case keys_1.KeySequence.CompareResult.SHADOW: {
|
331 | result.shadow.push(binding);
|
332 | break;
|
333 | }
|
334 | }
|
335 | }
|
336 | catch (error) {
|
337 | this.logger.warn(error);
|
338 | }
|
339 | }
|
340 | return result;
|
341 | }
|
342 | |
343 |
|
344 |
|
345 |
|
346 |
|
347 |
|
348 | getKeybindingsForCommand(commandId) {
|
349 | const result = [];
|
350 | const disabledBindings = new Set();
|
351 | for (let scope = KeybindingScope.END - 1; scope >= KeybindingScope.DEFAULT; scope--) {
|
352 | this.keymaps[scope].forEach(binding => {
|
353 | var _a;
|
354 | if ((_a = binding.command) === null || _a === void 0 ? void 0 : _a.startsWith('-')) {
|
355 | disabledBindings.add(JSON.stringify({ command: binding.command.substring(1), binding: binding.keybinding, context: binding.context, when: binding.when }));
|
356 | }
|
357 | else {
|
358 | const command = this.commandRegistry.getCommand(binding.command);
|
359 | if (command
|
360 | && command.id === commandId
|
361 | && !disabledBindings.has(JSON.stringify({ command: binding.command, binding: binding.keybinding, context: binding.context, when: binding.when }))) {
|
362 | result.push({ ...binding, scope });
|
363 | }
|
364 | }
|
365 | });
|
366 | }
|
367 | return result;
|
368 | }
|
369 | isActive(binding) {
|
370 | |
371 |
|
372 | if (this.isPseudoCommand(binding.command)) {
|
373 | return true;
|
374 | }
|
375 | const command = this.commandRegistry.getCommand(binding.command);
|
376 | return !!command && !!this.commandRegistry.getActiveHandler(command.id);
|
377 | }
|
378 | |
379 |
|
380 |
|
381 |
|
382 |
|
383 |
|
384 | executeKeyBinding(binding, event) {
|
385 | if (this.isPseudoCommand(binding.command)) {
|
386 |
|
387 | }
|
388 | else {
|
389 | const command = this.commandRegistry.getCommand(binding.command);
|
390 | if (command) {
|
391 | if (this.commandRegistry.isEnabled(binding.command, binding.args)) {
|
392 | this.commandRegistry.executeCommand(binding.command, binding.args)
|
393 | .catch(e => console.error('Failed to execute command:', e));
|
394 | }
|
395 | |
396 |
|
397 | event.preventDefault();
|
398 | event.stopPropagation();
|
399 | }
|
400 | }
|
401 | }
|
402 | |
403 |
|
404 |
|
405 | isEnabled(binding, event) {
|
406 | return this.isEnabledInScope(binding, event.target);
|
407 | }
|
408 | isEnabledInScope(binding, target) {
|
409 | const context = binding.context && this.contexts[binding.context];
|
410 | if (context && !context.isEnabled(binding)) {
|
411 | return false;
|
412 | }
|
413 | if (binding.when && !this.whenContextService.match(binding.when, target)) {
|
414 | return false;
|
415 | }
|
416 | return true;
|
417 | }
|
418 | dispatchCommand(id, target) {
|
419 | const keybindings = this.getKeybindingsForCommand(id);
|
420 | if (keybindings.length) {
|
421 | for (const keyCode of this.resolveKeybinding(keybindings[0])) {
|
422 | this.dispatchKeyDown(keyCode, target);
|
423 | }
|
424 | }
|
425 | }
|
426 | dispatchKeyDown(input, target = document.activeElement || window) {
|
427 | const eventInit = this.asKeyboardEventInit(input);
|
428 | const emulatedKeyboardEvent = new KeyboardEvent('keydown', eventInit);
|
429 | target.dispatchEvent(emulatedKeyboardEvent);
|
430 | }
|
431 | asKeyboardEventInit(input) {
|
432 | if (typeof input === 'string') {
|
433 | return this.asKeyboardEventInit(keys_1.KeyCode.createKeyCode(input));
|
434 | }
|
435 | if (input instanceof keys_1.KeyCode) {
|
436 | return {
|
437 | metaKey: input.meta,
|
438 | shiftKey: input.shift,
|
439 | altKey: input.alt,
|
440 | ctrlKey: input.ctrl,
|
441 | code: input.key && input.key.code,
|
442 | key: (input && input.character) || (input.key && input.key.code),
|
443 | keyCode: input.key && input.key.keyCode
|
444 | };
|
445 | }
|
446 | return input;
|
447 | }
|
448 | registerEventListeners(win) {
|
449 | |
450 |
|
451 |
|
452 |
|
453 |
|
454 | let inComposition = false;
|
455 | const compositionStart = () => {
|
456 | inComposition = true;
|
457 | };
|
458 | win.document.addEventListener('compositionstart', compositionStart);
|
459 | const compositionEnd = () => {
|
460 | inComposition = false;
|
461 | };
|
462 | win.document.addEventListener('compositionend', compositionEnd);
|
463 | const keydown = (event) => {
|
464 | if (inComposition !== true) {
|
465 | this.run(event);
|
466 | }
|
467 | };
|
468 | win.document.addEventListener('keydown', keydown, true);
|
469 | return disposable_1.Disposable.create(() => {
|
470 | win.document.removeEventListener('compositionstart', compositionStart);
|
471 | win.document.removeEventListener('compositionend', compositionEnd);
|
472 | win.document.removeEventListener('keydown', keydown);
|
473 | });
|
474 | }
|
475 | |
476 |
|
477 |
|
478 | run(event) {
|
479 | if (event.defaultPrevented) {
|
480 | return;
|
481 | }
|
482 | const eventDispatch = this.corePreferences['keyboard.dispatch'];
|
483 | const keyCode = keys_1.KeyCode.createKeyCode(event, eventDispatch);
|
484 | |
485 |
|
486 | if (keyCode.isModifierOnly()) {
|
487 | return;
|
488 | }
|
489 | this.keyboardLayoutService.validateKeyCode(keyCode);
|
490 | this.keySequence.push(keyCode);
|
491 | const match = this.matchKeybinding(this.keySequence, event);
|
492 | if (match && match.kind === 'partial') {
|
493 |
|
494 | event.preventDefault();
|
495 | event.stopPropagation();
|
496 | this.statusBar.setElement('keybinding-status', {
|
497 | text: nls_1.nls.localize('theia/core/keybindingStatus', '{0} was pressed, waiting for more keys', `(${this.acceleratorForSequence(this.keySequence, '+')})`),
|
498 | alignment: status_bar_1.StatusBarAlignment.LEFT,
|
499 | priority: 2
|
500 | });
|
501 | }
|
502 | else {
|
503 | if (match && match.kind === 'full') {
|
504 | this.executeKeyBinding(match.binding, event);
|
505 | }
|
506 | this.keySequence = [];
|
507 | this.statusBar.removeElement('keybinding-status');
|
508 | }
|
509 | }
|
510 | |
511 |
|
512 |
|
513 |
|
514 |
|
515 |
|
516 |
|
517 |
|
518 |
|
519 | matchKeybinding(keySequence, event) {
|
520 | let disabled;
|
521 | const isEnabled = (binding) => {
|
522 | if (event && !this.isEnabled(binding, event)) {
|
523 | return false;
|
524 | }
|
525 | const { command, context, when, keybinding } = binding;
|
526 | if (!this.isUsable(binding)) {
|
527 | disabled = disabled || new Set();
|
528 | disabled.add(JSON.stringify({ command: command.substring(1), context, when, keybinding }));
|
529 | return false;
|
530 | }
|
531 | return !(disabled === null || disabled === void 0 ? void 0 : disabled.has(JSON.stringify({ command, context, when, keybinding })));
|
532 | };
|
533 | for (let scope = KeybindingScope.END; --scope >= KeybindingScope.DEFAULT;) {
|
534 | for (const binding of this.keymaps[scope]) {
|
535 | const resolved = this.resolveKeybinding(binding);
|
536 | const compareResult = keys_1.KeySequence.compare(keySequence, resolved);
|
537 | if (compareResult === keys_1.KeySequence.CompareResult.FULL && isEnabled(binding)) {
|
538 | return { kind: 'full', binding };
|
539 | }
|
540 | if (compareResult === keys_1.KeySequence.CompareResult.PARTIAL && isEnabled(binding)) {
|
541 | return { kind: 'partial', binding };
|
542 | }
|
543 | }
|
544 | }
|
545 | return undefined;
|
546 | }
|
547 | |
548 |
|
549 |
|
550 |
|
551 | isUsable(binding) {
|
552 | return binding.command.charAt(0) !== '-';
|
553 | }
|
554 | |
555 |
|
556 |
|
557 |
|
558 | getUsableBindings(bindings) {
|
559 | return bindings.filter(binding => this.isUsable(binding));
|
560 | }
|
561 | |
562 |
|
563 |
|
564 |
|
565 |
|
566 |
|
567 |
|
568 | isPseudoCommand(commandId) {
|
569 | return commandId === KeybindingRegistry_1.PASSTHROUGH_PSEUDO_COMMAND;
|
570 | }
|
571 | |
572 |
|
573 |
|
574 |
|
575 |
|
576 | setKeymap(scope, bindings) {
|
577 | this.resetKeybindingsForScope(scope);
|
578 | this.toResetKeymap.set(scope, this.doRegisterKeybindings(bindings, scope));
|
579 | this.keybindingsChanged.fire(undefined);
|
580 | }
|
581 | |
582 |
|
583 |
|
584 |
|
585 | resetKeybindingsForScope(scope) {
|
586 | const toReset = this.toResetKeymap.get(scope);
|
587 | if (toReset) {
|
588 | toReset.dispose();
|
589 | }
|
590 | }
|
591 | |
592 |
|
593 |
|
594 | resetKeybindings() {
|
595 | for (let i = KeybindingScope.DEFAULT + 1; i < KeybindingScope.END; i++) {
|
596 | this.keymaps[i] = [];
|
597 | }
|
598 | }
|
599 | |
600 |
|
601 |
|
602 |
|
603 |
|
604 | getKeybindingsByScope(scope) {
|
605 | return this.keymaps[scope];
|
606 | }
|
607 | };
|
608 | KeybindingRegistry.PASSTHROUGH_PSEUDO_COMMAND = 'passthrough';
|
609 | __decorate([
|
610 | (0, inversify_1.inject)(core_preferences_1.CorePreferences),
|
611 | __metadata("design:type", Object)
|
612 | ], KeybindingRegistry.prototype, "corePreferences", void 0);
|
613 | __decorate([
|
614 | (0, inversify_1.inject)(keyboard_layout_service_1.KeyboardLayoutService),
|
615 | __metadata("design:type", keyboard_layout_service_1.KeyboardLayoutService)
|
616 | ], KeybindingRegistry.prototype, "keyboardLayoutService", void 0);
|
617 | __decorate([
|
618 | (0, inversify_1.inject)(contribution_provider_1.ContributionProvider),
|
619 | (0, inversify_1.named)(exports.KeybindingContext),
|
620 | __metadata("design:type", Object)
|
621 | ], KeybindingRegistry.prototype, "contextProvider", void 0);
|
622 | __decorate([
|
623 | (0, inversify_1.inject)(command_1.CommandRegistry),
|
624 | __metadata("design:type", command_1.CommandRegistry)
|
625 | ], KeybindingRegistry.prototype, "commandRegistry", void 0);
|
626 | __decorate([
|
627 | (0, inversify_1.inject)(contribution_provider_1.ContributionProvider),
|
628 | (0, inversify_1.named)(exports.KeybindingContribution),
|
629 | __metadata("design:type", Object)
|
630 | ], KeybindingRegistry.prototype, "contributions", void 0);
|
631 | __decorate([
|
632 | (0, inversify_1.inject)(status_bar_1.StatusBar),
|
633 | __metadata("design:type", Object)
|
634 | ], KeybindingRegistry.prototype, "statusBar", void 0);
|
635 | __decorate([
|
636 | (0, inversify_1.inject)(logger_1.ILogger),
|
637 | __metadata("design:type", Object)
|
638 | ], KeybindingRegistry.prototype, "logger", void 0);
|
639 | __decorate([
|
640 | (0, inversify_1.inject)(context_key_service_1.ContextKeyService),
|
641 | __metadata("design:type", Object)
|
642 | ], KeybindingRegistry.prototype, "whenContextService", void 0);
|
643 | KeybindingRegistry = KeybindingRegistry_1 = __decorate([
|
644 | (0, inversify_1.injectable)()
|
645 | ], KeybindingRegistry);
|
646 | exports.KeybindingRegistry = KeybindingRegistry;
|
647 | (function (KeybindingRegistry) {
|
648 | class KeybindingsResult {
|
649 | constructor() {
|
650 | this.full = [];
|
651 | this.partial = [];
|
652 | this.shadow = [];
|
653 | }
|
654 | |
655 |
|
656 |
|
657 |
|
658 |
|
659 |
|
660 | merge(other) {
|
661 | this.full.push(...other.full);
|
662 | this.partial.push(...other.partial);
|
663 | this.shadow.push(...other.shadow);
|
664 | return this;
|
665 | }
|
666 | |
667 |
|
668 |
|
669 |
|
670 |
|
671 |
|
672 | filter(fn) {
|
673 | const result = new KeybindingsResult();
|
674 | result.full = this.full.filter(fn);
|
675 | result.partial = this.partial.filter(fn);
|
676 | result.shadow = this.shadow.filter(fn);
|
677 | return result;
|
678 | }
|
679 | }
|
680 | KeybindingRegistry.KeybindingsResult = KeybindingsResult;
|
681 | })(KeybindingRegistry = exports.KeybindingRegistry || (exports.KeybindingRegistry = {}));
|
682 | exports.KeybindingRegistry = KeybindingRegistry;
|
683 |
|
\ | No newline at end of file |