UNPKG

4.67 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.QuickCommandFrontendContribution = void 0;
4const tslib_1 = require("tslib");
5// *****************************************************************************
6// Copyright (C) 2017 TypeFox and others.
7//
8// This program and the accompanying materials are made available under the
9// terms of the Eclipse Public License v. 2.0 which is available at
10// http://www.eclipse.org/legal/epl-2.0.
11//
12// This Source Code may also be made available under the following Secondary
13// Licenses when the conditions for such availability set forth in the Eclipse
14// Public License v. 2.0 are satisfied: GNU General Public License, version 2
15// with the GNU Classpath Exception which is available at
16// https://www.gnu.org/software/classpath/license.html.
17//
18// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
19// *****************************************************************************
20const inversify_1 = require("inversify");
21const common_1 = require("../../common");
22const common_frontend_contribution_1 = require("../common-frontend-contribution");
23const quick_command_service_1 = require("./quick-command-service");
24const quick_input_service_1 = require("./quick-input-service");
25const dialogs_1 = require("../dialogs");
26let QuickCommandFrontendContribution = class QuickCommandFrontendContribution {
27 registerCommands(commands) {
28 commands.registerCommand(quick_command_service_1.quickCommand, {
29 execute: () => {
30 var _a;
31 (_a = this.quickInputService) === null || _a === void 0 ? void 0 : _a.open('>');
32 }
33 });
34 commands.registerCommand(quick_command_service_1.CLEAR_COMMAND_HISTORY, {
35 execute: async () => {
36 const shouldClear = await new dialogs_1.ConfirmDialog({
37 title: common_1.nls.localizeByDefault('Clear Command History'),
38 msg: common_1.nls.localizeByDefault('Do you want to clear the history of recently used commands?'),
39 ok: common_1.nls.localizeByDefault('Clear'),
40 cancel: dialogs_1.Dialog.CANCEL,
41 }).open();
42 if (shouldClear) {
43 commands.clearCommandHistory();
44 }
45 }
46 });
47 commands.registerCommand(quick_command_service_1.CLOSE_QUICK_OPEN, {
48 execute: () => { var _a; return (_a = this.quickInputService) === null || _a === void 0 ? void 0 : _a.hide(); }
49 });
50 }
51 registerMenus(menus) {
52 menus.registerMenuAction(common_frontend_contribution_1.CommonMenus.VIEW_PRIMARY, {
53 commandId: quick_command_service_1.quickCommand.id,
54 label: common_1.nls.localizeByDefault('Command Palette...')
55 });
56 menus.registerMenuAction(common_frontend_contribution_1.CommonMenus.MANAGE_GENERAL, {
57 commandId: quick_command_service_1.quickCommand.id,
58 label: common_1.nls.localizeByDefault('Command Palette...'),
59 order: '0'
60 });
61 }
62 registerKeybindings(keybindings) {
63 keybindings.registerKeybinding({
64 command: quick_command_service_1.quickCommand.id,
65 keybinding: 'f1'
66 });
67 keybindings.registerKeybinding({
68 command: quick_command_service_1.quickCommand.id,
69 keybinding: 'ctrlcmd+shift+p'
70 });
71 keybindings.registerKeybinding({
72 command: quick_command_service_1.CLOSE_QUICK_OPEN.id,
73 keybinding: 'esc',
74 when: 'inQuickOpen'
75 });
76 keybindings.registerKeybinding({
77 command: quick_command_service_1.CLOSE_QUICK_OPEN.id,
78 keybinding: 'shift+esc',
79 when: 'inQuickOpen'
80 });
81 }
82};
83(0, tslib_1.__decorate)([
84 (0, inversify_1.inject)(quick_input_service_1.QuickInputService),
85 (0, inversify_1.optional)(),
86 (0, tslib_1.__metadata)("design:type", Object)
87], QuickCommandFrontendContribution.prototype, "quickInputService", void 0);
88(0, tslib_1.__decorate)([
89 (0, inversify_1.inject)(quick_command_service_1.QuickCommandService),
90 (0, inversify_1.optional)(),
91 (0, tslib_1.__metadata)("design:type", quick_command_service_1.QuickCommandService)
92], QuickCommandFrontendContribution.prototype, "quickCommandService", void 0);
93QuickCommandFrontendContribution = (0, tslib_1.__decorate)([
94 (0, inversify_1.injectable)()
95], QuickCommandFrontendContribution);
96exports.QuickCommandFrontendContribution = QuickCommandFrontendContribution;
97//# sourceMappingURL=quick-command-frontend-contribution.js.map
\No newline at end of file