@theia/keymaps 1.45.1 → 1.46.0-next.72

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.
@@ -1,295 +1,295 @@
1
- "use strict";
2
- // *****************************************************************************
3
- // Copyright (C) 2018 TypeFox and others.
4
- //
5
- // This program and the accompanying materials are made available under the
6
- // terms of the Eclipse Public License v. 2.0 which is available at
7
- // http://www.eclipse.org/legal/epl-2.0.
8
- //
9
- // This Source Code may also be made available under the following Secondary
10
- // Licenses when the conditions for such availability set forth in the Eclipse
11
- // Public License v. 2.0 are satisfied: GNU General Public License, version 2
12
- // with the GNU Classpath Exception which is available at
13
- // https://www.gnu.org/software/classpath/license.html.
14
- //
15
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
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
- Object.defineProperty(exports, "__esModule", { value: true });
27
- exports.KeymapsFrontendContribution = exports.KeymapsCommands = void 0;
28
- const inversify_1 = require("@theia/core/shared/inversify");
29
- const common_1 = require("@theia/core/lib/common");
30
- const browser_1 = require("@theia/core/lib/browser");
31
- const clipboard_service_1 = require("@theia/core/lib/browser/clipboard-service");
32
- const common_frontend_contribution_1 = require("@theia/core/lib/browser/common-frontend-contribution");
33
- const keymaps_service_1 = require("./keymaps-service");
34
- const keybinding_1 = require("@theia/core/lib/common/keybinding");
35
- const keybindings_widget_1 = require("./keybindings-widget");
36
- const nls_1 = require("@theia/core/lib/common/nls");
37
- var KeymapsCommands;
38
- (function (KeymapsCommands) {
39
- KeymapsCommands.OPEN_KEYMAPS = common_1.Command.toDefaultLocalizedCommand({
40
- id: 'keymaps:open',
41
- category: common_frontend_contribution_1.CommonCommands.PREFERENCES_CATEGORY,
42
- label: 'Open Keyboard Shortcuts',
43
- });
44
- KeymapsCommands.OPEN_KEYMAPS_JSON = common_1.Command.toDefaultLocalizedCommand({
45
- id: 'keymaps:openJson',
46
- category: common_frontend_contribution_1.CommonCommands.PREFERENCES_CATEGORY,
47
- label: 'Open Keyboard Shortcuts (JSON)',
48
- });
49
- KeymapsCommands.OPEN_KEYMAPS_JSON_TOOLBAR = {
50
- id: 'keymaps:openJson.toolbar',
51
- iconClass: (0, browser_1.codicon)('json')
52
- };
53
- KeymapsCommands.CLEAR_KEYBINDINGS_SEARCH = {
54
- id: 'keymaps.clearSearch',
55
- iconClass: (0, browser_1.codicon)('clear-all')
56
- };
57
- KeymapsCommands.COPY_KEYBINDING = common_1.Command.toLocalizedCommand({
58
- id: 'keymaps:keybinding.copy',
59
- category: common_frontend_contribution_1.CommonCommands.PREFERENCES_CATEGORY,
60
- label: 'Copy Keybinding'
61
- }, 'theia/keymaps/keybinding/copy', common_frontend_contribution_1.CommonCommands.PREFERENCES_CATEGORY_KEY);
62
- KeymapsCommands.COPY_COMMAND_ID = common_1.Command.toLocalizedCommand({
63
- id: 'keymaps:keybinding.copyCommandId',
64
- category: common_frontend_contribution_1.CommonCommands.PREFERENCES_CATEGORY,
65
- label: 'Copy Keybinding Command ID'
66
- }, 'theia/keymaps/keybinding/copyCommandId', common_frontend_contribution_1.CommonCommands.PREFERENCES_CATEGORY_KEY);
67
- KeymapsCommands.COPY_COMMAND_TITLE = common_1.Command.toLocalizedCommand({
68
- id: 'keymaps:keybinding.copyCommandTitle',
69
- category: common_frontend_contribution_1.CommonCommands.PREFERENCES_CATEGORY,
70
- label: 'Copy Keybinding Command Title'
71
- }, 'theia/keymaps/keybinding/copyCommandTitle', common_frontend_contribution_1.CommonCommands.PREFERENCES_CATEGORY_KEY);
72
- KeymapsCommands.EDIT_KEYBINDING = common_1.Command.toLocalizedCommand({
73
- id: 'keymaps:keybinding.edit',
74
- category: common_frontend_contribution_1.CommonCommands.PREFERENCES_CATEGORY,
75
- label: 'Edit Keybinding...'
76
- }, 'theia/keymaps/keybinding/edit', common_frontend_contribution_1.CommonCommands.PREFERENCES_CATEGORY_KEY);
77
- KeymapsCommands.EDIT_WHEN_EXPRESSION = common_1.Command.toLocalizedCommand({
78
- id: 'keymaps:keybinding.editWhenExpression',
79
- category: common_frontend_contribution_1.CommonCommands.PREFERENCES_CATEGORY,
80
- label: 'Edit Keybinding When Expression...'
81
- }, 'theia/keymaps/keybinding/editWhenExpression', common_frontend_contribution_1.CommonCommands.PREFERENCES_CATEGORY_KEY);
82
- KeymapsCommands.ADD_KEYBINDING = common_1.Command.toDefaultLocalizedCommand({
83
- id: 'keymaps:keybinding.add',
84
- category: common_frontend_contribution_1.CommonCommands.PREFERENCES_CATEGORY,
85
- label: 'Add Keybinding...'
86
- });
87
- KeymapsCommands.REMOVE_KEYBINDING = common_1.Command.toDefaultLocalizedCommand({
88
- id: 'keymaps:keybinding.remove',
89
- category: common_frontend_contribution_1.CommonCommands.PREFERENCES_CATEGORY,
90
- label: 'Remove Keybinding'
91
- });
92
- KeymapsCommands.RESET_KEYBINDING = common_1.Command.toDefaultLocalizedCommand({
93
- id: 'keymaps:keybinding.reset',
94
- category: common_frontend_contribution_1.CommonCommands.PREFERENCES_CATEGORY,
95
- label: 'Reset Keybinding'
96
- });
97
- KeymapsCommands.SHOW_SAME = common_1.Command.toDefaultLocalizedCommand({
98
- id: 'keymaps:keybinding.showSame',
99
- category: common_frontend_contribution_1.CommonCommands.PREFERENCES_CATEGORY,
100
- label: 'Show Same Keybindings'
101
- });
102
- })(KeymapsCommands = exports.KeymapsCommands || (exports.KeymapsCommands = {}));
103
- let KeymapsFrontendContribution = class KeymapsFrontendContribution extends browser_1.AbstractViewContribution {
104
- constructor() {
105
- super({
106
- widgetId: keybindings_widget_1.KeybindingWidget.ID,
107
- widgetName: keybindings_widget_1.KeybindingWidget.LABEL,
108
- defaultWidgetOptions: {
109
- area: 'main'
110
- },
111
- });
112
- }
113
- registerCommands(commands) {
114
- commands.registerCommand(KeymapsCommands.OPEN_KEYMAPS, {
115
- isEnabled: () => true,
116
- execute: () => this.openView({ activate: true })
117
- });
118
- commands.registerCommand(KeymapsCommands.OPEN_KEYMAPS_JSON, {
119
- isEnabled: () => true,
120
- execute: () => this.keymaps.open()
121
- });
122
- commands.registerCommand(KeymapsCommands.OPEN_KEYMAPS_JSON_TOOLBAR, {
123
- isEnabled: w => this.withWidget(w, () => true),
124
- isVisible: w => this.withWidget(w, () => true),
125
- execute: w => this.withWidget(w, widget => this.keymaps.open(widget)),
126
- });
127
- commands.registerCommand(KeymapsCommands.CLEAR_KEYBINDINGS_SEARCH, {
128
- isEnabled: w => this.withWidget(w, widget => widget.hasSearch()),
129
- isVisible: w => this.withWidget(w, () => true),
130
- execute: w => this.withWidget(w, widget => widget.clearSearch()),
131
- });
132
- commands.registerCommand(KeymapsCommands.COPY_KEYBINDING, {
133
- isEnabled: (...args) => this.withItem(() => true, ...args),
134
- isVisible: (...args) => this.withItem(() => true, ...args),
135
- execute: (...args) => this.withItem(item => this.clipboard.writeText(JSON.stringify(keybinding_1.Keybinding.apiObjectify(keybindings_widget_1.KeybindingItem.keybinding(item)), undefined, ' ')), ...args)
136
- });
137
- commands.registerCommand(KeymapsCommands.COPY_COMMAND_ID, {
138
- isEnabled: (...args) => this.withItem(() => true, ...args),
139
- isVisible: (...args) => this.withItem(() => true, ...args),
140
- execute: (...args) => this.withItem(item => this.clipboard.writeText(item.command.id), ...args)
141
- });
142
- commands.registerCommand(KeymapsCommands.COPY_COMMAND_TITLE, {
143
- isEnabled: (...args) => this.withItem(item => !!item.command.label, ...args),
144
- isVisible: (...args) => this.withItem(() => true, ...args),
145
- execute: (...args) => this.withItem(item => this.clipboard.writeText(item.command.label), ...args)
146
- });
147
- commands.registerCommand(KeymapsCommands.EDIT_KEYBINDING, {
148
- isEnabled: (...args) => this.withWidgetItem(() => true, ...args),
149
- isVisible: (...args) => this.withWidgetItem(() => true, ...args),
150
- execute: (...args) => this.withWidgetItem((item, widget) => widget.editKeybinding(item), ...args)
151
- });
152
- commands.registerCommand(KeymapsCommands.EDIT_WHEN_EXPRESSION, {
153
- isEnabled: (...args) => this.withWidgetItem(item => !!item.keybinding, ...args),
154
- isVisible: (...args) => this.withWidgetItem(() => true, ...args),
155
- execute: (...args) => this.withWidgetItem((item, widget) => widget.editWhenExpression(item), ...args)
156
- });
157
- commands.registerCommand(KeymapsCommands.ADD_KEYBINDING, {
158
- isEnabled: (...args) => this.withWidgetItem(item => !!item.keybinding, ...args),
159
- isVisible: (...args) => this.withWidgetItem(item => !!item.keybinding, ...args),
160
- execute: (...args) => this.withWidgetItem((item, widget) => widget.addKeybinding(item), ...args)
161
- });
162
- commands.registerCommand(KeymapsCommands.REMOVE_KEYBINDING, {
163
- isEnabled: (...args) => this.withItem(item => !!item.keybinding, ...args),
164
- isVisible: (...args) => this.withItem(() => true, ...args),
165
- execute: (...args) => this.withItem(item => this.keymaps.unsetKeybinding(item.keybinding), ...args)
166
- });
167
- commands.registerCommand(KeymapsCommands.RESET_KEYBINDING, {
168
- isEnabled: (...args) => this.withWidgetItem((item, widget) => widget.canResetKeybinding(item), ...args),
169
- isVisible: (...args) => this.withWidgetItem(() => true, ...args),
170
- execute: (...args) => this.withWidgetItem((item, widget) => widget.resetKeybinding(item), ...args)
171
- });
172
- commands.registerCommand(KeymapsCommands.SHOW_SAME, {
173
- isEnabled: (...args) => this.withWidgetItem(item => !!item.keybinding, ...args),
174
- isVisible: (...args) => this.withWidgetItem(() => true, ...args),
175
- execute: (...args) => this.withWidgetItem((item, widget) => widget.showSameKeybindings(item), ...args)
176
- });
177
- }
178
- registerMenus(menus) {
179
- menus.registerMenuAction(common_frontend_contribution_1.CommonMenus.FILE_SETTINGS_SUBMENU_OPEN, {
180
- commandId: KeymapsCommands.OPEN_KEYMAPS.id,
181
- label: nls_1.nls.localizeByDefault('Keyboard Shortcuts'),
182
- order: 'a20'
183
- });
184
- menus.registerMenuAction(common_frontend_contribution_1.CommonMenus.MANAGE_SETTINGS, {
185
- commandId: KeymapsCommands.OPEN_KEYMAPS.id,
186
- label: nls_1.nls.localizeByDefault('Keyboard Shortcuts'),
187
- order: 'a30'
188
- });
189
- menus.registerMenuAction(keybindings_widget_1.KeybindingWidget.COPY_MENU, {
190
- commandId: KeymapsCommands.COPY_KEYBINDING.id,
191
- label: nls_1.nls.localizeByDefault('Copy'),
192
- order: 'a'
193
- });
194
- menus.registerMenuAction(keybindings_widget_1.KeybindingWidget.COPY_MENU, {
195
- commandId: KeymapsCommands.COPY_COMMAND_ID.id,
196
- label: nls_1.nls.localizeByDefault('Copy Command ID'),
197
- order: 'b'
198
- });
199
- menus.registerMenuAction(keybindings_widget_1.KeybindingWidget.COPY_MENU, {
200
- commandId: KeymapsCommands.COPY_COMMAND_TITLE.id,
201
- label: nls_1.nls.localizeByDefault('Copy Command Title'),
202
- order: 'c'
203
- });
204
- menus.registerMenuAction(keybindings_widget_1.KeybindingWidget.EDIT_MENU, {
205
- commandId: KeymapsCommands.EDIT_KEYBINDING.id,
206
- label: nls_1.nls.localize('theia/keymaps/editKeybinding', 'Edit Keybinding...'),
207
- order: 'a'
208
- });
209
- menus.registerMenuAction(keybindings_widget_1.KeybindingWidget.EDIT_MENU, {
210
- commandId: KeymapsCommands.EDIT_WHEN_EXPRESSION.id,
211
- label: nls_1.nls.localize('theia/keymaps/editWhenExpression', 'Edit When Expression...'),
212
- order: 'b'
213
- });
214
- menus.registerMenuAction(keybindings_widget_1.KeybindingWidget.ADD_MENU, {
215
- commandId: KeymapsCommands.ADD_KEYBINDING.id,
216
- label: nls_1.nls.localizeByDefault('Add Keybinding...'),
217
- order: 'a'
218
- });
219
- menus.registerMenuAction(keybindings_widget_1.KeybindingWidget.REMOVE_MENU, {
220
- commandId: KeymapsCommands.REMOVE_KEYBINDING.id,
221
- label: nls_1.nls.localizeByDefault('Remove Keybinding'),
222
- order: 'a'
223
- });
224
- menus.registerMenuAction(keybindings_widget_1.KeybindingWidget.REMOVE_MENU, {
225
- commandId: KeymapsCommands.RESET_KEYBINDING.id,
226
- label: nls_1.nls.localizeByDefault('Reset Keybinding'),
227
- order: 'b'
228
- });
229
- menus.registerMenuAction(keybindings_widget_1.KeybindingWidget.SHOW_MENU, {
230
- commandId: KeymapsCommands.SHOW_SAME.id,
231
- label: nls_1.nls.localizeByDefault('Show Same Keybindings'),
232
- order: 'a'
233
- });
234
- }
235
- registerKeybindings(keybindings) {
236
- keybindings.registerKeybinding({
237
- command: KeymapsCommands.OPEN_KEYMAPS.id,
238
- keybinding: 'ctrl+alt+,'
239
- });
240
- }
241
- async registerToolbarItems(toolbar) {
242
- const widget = await this.widget;
243
- const onDidChange = widget.onDidUpdate;
244
- toolbar.registerItem({
245
- id: KeymapsCommands.OPEN_KEYMAPS_JSON_TOOLBAR.id,
246
- command: KeymapsCommands.OPEN_KEYMAPS_JSON_TOOLBAR.id,
247
- tooltip: nls_1.nls.localizeByDefault('Open Keyboard Shortcuts (JSON)'),
248
- priority: 0,
249
- });
250
- toolbar.registerItem({
251
- id: KeymapsCommands.CLEAR_KEYBINDINGS_SEARCH.id,
252
- command: KeymapsCommands.CLEAR_KEYBINDINGS_SEARCH.id,
253
- tooltip: nls_1.nls.localizeByDefault('Clear Keybindings Search Input'),
254
- priority: 1,
255
- onDidChange,
256
- });
257
- }
258
- /**
259
- * Determine if the current widget is the keybindings widget.
260
- */
261
- withWidget(widget = this.tryGetWidget(), fn) {
262
- if (widget instanceof keybindings_widget_1.KeybindingWidget && widget.id === keybindings_widget_1.KeybindingWidget.ID) {
263
- return fn(widget);
264
- }
265
- return false;
266
- }
267
- withItem(fn, ...args) {
268
- const [item] = args;
269
- if (keybindings_widget_1.KeybindingItem.is(item)) {
270
- return fn(item, args.slice(1));
271
- }
272
- return false;
273
- }
274
- withWidgetItem(fn, ...args) {
275
- const [item, widget] = args;
276
- if (widget instanceof keybindings_widget_1.KeybindingWidget && widget.id === keybindings_widget_1.KeybindingWidget.ID && keybindings_widget_1.KeybindingItem.is(item)) {
277
- return fn(item, widget, args.slice(2));
278
- }
279
- return false;
280
- }
281
- };
282
- __decorate([
283
- (0, inversify_1.inject)(keymaps_service_1.KeymapsService),
284
- __metadata("design:type", keymaps_service_1.KeymapsService)
285
- ], KeymapsFrontendContribution.prototype, "keymaps", void 0);
286
- __decorate([
287
- (0, inversify_1.inject)(clipboard_service_1.ClipboardService),
288
- __metadata("design:type", Object)
289
- ], KeymapsFrontendContribution.prototype, "clipboard", void 0);
290
- KeymapsFrontendContribution = __decorate([
291
- (0, inversify_1.injectable)(),
292
- __metadata("design:paramtypes", [])
293
- ], KeymapsFrontendContribution);
294
- exports.KeymapsFrontendContribution = KeymapsFrontendContribution;
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2018 TypeFox and others.
4
+ //
5
+ // This program and the accompanying materials are made available under the
6
+ // terms of the Eclipse Public License v. 2.0 which is available at
7
+ // http://www.eclipse.org/legal/epl-2.0.
8
+ //
9
+ // This Source Code may also be made available under the following Secondary
10
+ // Licenses when the conditions for such availability set forth in the Eclipse
11
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
12
+ // with the GNU Classpath Exception which is available at
13
+ // https://www.gnu.org/software/classpath/license.html.
14
+ //
15
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
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
+ Object.defineProperty(exports, "__esModule", { value: true });
27
+ exports.KeymapsFrontendContribution = exports.KeymapsCommands = void 0;
28
+ const inversify_1 = require("@theia/core/shared/inversify");
29
+ const common_1 = require("@theia/core/lib/common");
30
+ const browser_1 = require("@theia/core/lib/browser");
31
+ const clipboard_service_1 = require("@theia/core/lib/browser/clipboard-service");
32
+ const common_frontend_contribution_1 = require("@theia/core/lib/browser/common-frontend-contribution");
33
+ const keymaps_service_1 = require("./keymaps-service");
34
+ const keybinding_1 = require("@theia/core/lib/common/keybinding");
35
+ const keybindings_widget_1 = require("./keybindings-widget");
36
+ const nls_1 = require("@theia/core/lib/common/nls");
37
+ var KeymapsCommands;
38
+ (function (KeymapsCommands) {
39
+ KeymapsCommands.OPEN_KEYMAPS = common_1.Command.toDefaultLocalizedCommand({
40
+ id: 'keymaps:open',
41
+ category: common_frontend_contribution_1.CommonCommands.PREFERENCES_CATEGORY,
42
+ label: 'Open Keyboard Shortcuts',
43
+ });
44
+ KeymapsCommands.OPEN_KEYMAPS_JSON = common_1.Command.toDefaultLocalizedCommand({
45
+ id: 'keymaps:openJson',
46
+ category: common_frontend_contribution_1.CommonCommands.PREFERENCES_CATEGORY,
47
+ label: 'Open Keyboard Shortcuts (JSON)',
48
+ });
49
+ KeymapsCommands.OPEN_KEYMAPS_JSON_TOOLBAR = {
50
+ id: 'keymaps:openJson.toolbar',
51
+ iconClass: (0, browser_1.codicon)('json')
52
+ };
53
+ KeymapsCommands.CLEAR_KEYBINDINGS_SEARCH = {
54
+ id: 'keymaps.clearSearch',
55
+ iconClass: (0, browser_1.codicon)('clear-all')
56
+ };
57
+ KeymapsCommands.COPY_KEYBINDING = common_1.Command.toLocalizedCommand({
58
+ id: 'keymaps:keybinding.copy',
59
+ category: common_frontend_contribution_1.CommonCommands.PREFERENCES_CATEGORY,
60
+ label: 'Copy Keybinding'
61
+ }, 'theia/keymaps/keybinding/copy', common_frontend_contribution_1.CommonCommands.PREFERENCES_CATEGORY_KEY);
62
+ KeymapsCommands.COPY_COMMAND_ID = common_1.Command.toLocalizedCommand({
63
+ id: 'keymaps:keybinding.copyCommandId',
64
+ category: common_frontend_contribution_1.CommonCommands.PREFERENCES_CATEGORY,
65
+ label: 'Copy Keybinding Command ID'
66
+ }, 'theia/keymaps/keybinding/copyCommandId', common_frontend_contribution_1.CommonCommands.PREFERENCES_CATEGORY_KEY);
67
+ KeymapsCommands.COPY_COMMAND_TITLE = common_1.Command.toLocalizedCommand({
68
+ id: 'keymaps:keybinding.copyCommandTitle',
69
+ category: common_frontend_contribution_1.CommonCommands.PREFERENCES_CATEGORY,
70
+ label: 'Copy Keybinding Command Title'
71
+ }, 'theia/keymaps/keybinding/copyCommandTitle', common_frontend_contribution_1.CommonCommands.PREFERENCES_CATEGORY_KEY);
72
+ KeymapsCommands.EDIT_KEYBINDING = common_1.Command.toLocalizedCommand({
73
+ id: 'keymaps:keybinding.edit',
74
+ category: common_frontend_contribution_1.CommonCommands.PREFERENCES_CATEGORY,
75
+ label: 'Edit Keybinding...'
76
+ }, 'theia/keymaps/keybinding/edit', common_frontend_contribution_1.CommonCommands.PREFERENCES_CATEGORY_KEY);
77
+ KeymapsCommands.EDIT_WHEN_EXPRESSION = common_1.Command.toLocalizedCommand({
78
+ id: 'keymaps:keybinding.editWhenExpression',
79
+ category: common_frontend_contribution_1.CommonCommands.PREFERENCES_CATEGORY,
80
+ label: 'Edit Keybinding When Expression...'
81
+ }, 'theia/keymaps/keybinding/editWhenExpression', common_frontend_contribution_1.CommonCommands.PREFERENCES_CATEGORY_KEY);
82
+ KeymapsCommands.ADD_KEYBINDING = common_1.Command.toDefaultLocalizedCommand({
83
+ id: 'keymaps:keybinding.add',
84
+ category: common_frontend_contribution_1.CommonCommands.PREFERENCES_CATEGORY,
85
+ label: 'Add Keybinding...'
86
+ });
87
+ KeymapsCommands.REMOVE_KEYBINDING = common_1.Command.toDefaultLocalizedCommand({
88
+ id: 'keymaps:keybinding.remove',
89
+ category: common_frontend_contribution_1.CommonCommands.PREFERENCES_CATEGORY,
90
+ label: 'Remove Keybinding'
91
+ });
92
+ KeymapsCommands.RESET_KEYBINDING = common_1.Command.toDefaultLocalizedCommand({
93
+ id: 'keymaps:keybinding.reset',
94
+ category: common_frontend_contribution_1.CommonCommands.PREFERENCES_CATEGORY,
95
+ label: 'Reset Keybinding'
96
+ });
97
+ KeymapsCommands.SHOW_SAME = common_1.Command.toDefaultLocalizedCommand({
98
+ id: 'keymaps:keybinding.showSame',
99
+ category: common_frontend_contribution_1.CommonCommands.PREFERENCES_CATEGORY,
100
+ label: 'Show Same Keybindings'
101
+ });
102
+ })(KeymapsCommands = exports.KeymapsCommands || (exports.KeymapsCommands = {}));
103
+ let KeymapsFrontendContribution = class KeymapsFrontendContribution extends browser_1.AbstractViewContribution {
104
+ constructor() {
105
+ super({
106
+ widgetId: keybindings_widget_1.KeybindingWidget.ID,
107
+ widgetName: keybindings_widget_1.KeybindingWidget.LABEL,
108
+ defaultWidgetOptions: {
109
+ area: 'main'
110
+ },
111
+ });
112
+ }
113
+ registerCommands(commands) {
114
+ commands.registerCommand(KeymapsCommands.OPEN_KEYMAPS, {
115
+ isEnabled: () => true,
116
+ execute: () => this.openView({ activate: true })
117
+ });
118
+ commands.registerCommand(KeymapsCommands.OPEN_KEYMAPS_JSON, {
119
+ isEnabled: () => true,
120
+ execute: () => this.keymaps.open()
121
+ });
122
+ commands.registerCommand(KeymapsCommands.OPEN_KEYMAPS_JSON_TOOLBAR, {
123
+ isEnabled: w => this.withWidget(w, () => true),
124
+ isVisible: w => this.withWidget(w, () => true),
125
+ execute: w => this.withWidget(w, widget => this.keymaps.open(widget)),
126
+ });
127
+ commands.registerCommand(KeymapsCommands.CLEAR_KEYBINDINGS_SEARCH, {
128
+ isEnabled: w => this.withWidget(w, widget => widget.hasSearch()),
129
+ isVisible: w => this.withWidget(w, () => true),
130
+ execute: w => this.withWidget(w, widget => widget.clearSearch()),
131
+ });
132
+ commands.registerCommand(KeymapsCommands.COPY_KEYBINDING, {
133
+ isEnabled: (...args) => this.withItem(() => true, ...args),
134
+ isVisible: (...args) => this.withItem(() => true, ...args),
135
+ execute: (...args) => this.withItem(item => this.clipboard.writeText(JSON.stringify(keybinding_1.Keybinding.apiObjectify(keybindings_widget_1.KeybindingItem.keybinding(item)), undefined, ' ')), ...args)
136
+ });
137
+ commands.registerCommand(KeymapsCommands.COPY_COMMAND_ID, {
138
+ isEnabled: (...args) => this.withItem(() => true, ...args),
139
+ isVisible: (...args) => this.withItem(() => true, ...args),
140
+ execute: (...args) => this.withItem(item => this.clipboard.writeText(item.command.id), ...args)
141
+ });
142
+ commands.registerCommand(KeymapsCommands.COPY_COMMAND_TITLE, {
143
+ isEnabled: (...args) => this.withItem(item => !!item.command.label, ...args),
144
+ isVisible: (...args) => this.withItem(() => true, ...args),
145
+ execute: (...args) => this.withItem(item => this.clipboard.writeText(item.command.label), ...args)
146
+ });
147
+ commands.registerCommand(KeymapsCommands.EDIT_KEYBINDING, {
148
+ isEnabled: (...args) => this.withWidgetItem(() => true, ...args),
149
+ isVisible: (...args) => this.withWidgetItem(() => true, ...args),
150
+ execute: (...args) => this.withWidgetItem((item, widget) => widget.editKeybinding(item), ...args)
151
+ });
152
+ commands.registerCommand(KeymapsCommands.EDIT_WHEN_EXPRESSION, {
153
+ isEnabled: (...args) => this.withWidgetItem(item => !!item.keybinding, ...args),
154
+ isVisible: (...args) => this.withWidgetItem(() => true, ...args),
155
+ execute: (...args) => this.withWidgetItem((item, widget) => widget.editWhenExpression(item), ...args)
156
+ });
157
+ commands.registerCommand(KeymapsCommands.ADD_KEYBINDING, {
158
+ isEnabled: (...args) => this.withWidgetItem(item => !!item.keybinding, ...args),
159
+ isVisible: (...args) => this.withWidgetItem(item => !!item.keybinding, ...args),
160
+ execute: (...args) => this.withWidgetItem((item, widget) => widget.addKeybinding(item), ...args)
161
+ });
162
+ commands.registerCommand(KeymapsCommands.REMOVE_KEYBINDING, {
163
+ isEnabled: (...args) => this.withItem(item => !!item.keybinding, ...args),
164
+ isVisible: (...args) => this.withItem(() => true, ...args),
165
+ execute: (...args) => this.withItem(item => this.keymaps.unsetKeybinding(item.keybinding), ...args)
166
+ });
167
+ commands.registerCommand(KeymapsCommands.RESET_KEYBINDING, {
168
+ isEnabled: (...args) => this.withWidgetItem((item, widget) => widget.canResetKeybinding(item), ...args),
169
+ isVisible: (...args) => this.withWidgetItem(() => true, ...args),
170
+ execute: (...args) => this.withWidgetItem((item, widget) => widget.resetKeybinding(item), ...args)
171
+ });
172
+ commands.registerCommand(KeymapsCommands.SHOW_SAME, {
173
+ isEnabled: (...args) => this.withWidgetItem(item => !!item.keybinding, ...args),
174
+ isVisible: (...args) => this.withWidgetItem(() => true, ...args),
175
+ execute: (...args) => this.withWidgetItem((item, widget) => widget.showSameKeybindings(item), ...args)
176
+ });
177
+ }
178
+ registerMenus(menus) {
179
+ menus.registerMenuAction(common_frontend_contribution_1.CommonMenus.FILE_SETTINGS_SUBMENU_OPEN, {
180
+ commandId: KeymapsCommands.OPEN_KEYMAPS.id,
181
+ label: nls_1.nls.localizeByDefault('Keyboard Shortcuts'),
182
+ order: 'a20'
183
+ });
184
+ menus.registerMenuAction(common_frontend_contribution_1.CommonMenus.MANAGE_SETTINGS, {
185
+ commandId: KeymapsCommands.OPEN_KEYMAPS.id,
186
+ label: nls_1.nls.localizeByDefault('Keyboard Shortcuts'),
187
+ order: 'a30'
188
+ });
189
+ menus.registerMenuAction(keybindings_widget_1.KeybindingWidget.COPY_MENU, {
190
+ commandId: KeymapsCommands.COPY_KEYBINDING.id,
191
+ label: nls_1.nls.localizeByDefault('Copy'),
192
+ order: 'a'
193
+ });
194
+ menus.registerMenuAction(keybindings_widget_1.KeybindingWidget.COPY_MENU, {
195
+ commandId: KeymapsCommands.COPY_COMMAND_ID.id,
196
+ label: nls_1.nls.localizeByDefault('Copy Command ID'),
197
+ order: 'b'
198
+ });
199
+ menus.registerMenuAction(keybindings_widget_1.KeybindingWidget.COPY_MENU, {
200
+ commandId: KeymapsCommands.COPY_COMMAND_TITLE.id,
201
+ label: nls_1.nls.localizeByDefault('Copy Command Title'),
202
+ order: 'c'
203
+ });
204
+ menus.registerMenuAction(keybindings_widget_1.KeybindingWidget.EDIT_MENU, {
205
+ commandId: KeymapsCommands.EDIT_KEYBINDING.id,
206
+ label: nls_1.nls.localize('theia/keymaps/editKeybinding', 'Edit Keybinding...'),
207
+ order: 'a'
208
+ });
209
+ menus.registerMenuAction(keybindings_widget_1.KeybindingWidget.EDIT_MENU, {
210
+ commandId: KeymapsCommands.EDIT_WHEN_EXPRESSION.id,
211
+ label: nls_1.nls.localize('theia/keymaps/editWhenExpression', 'Edit When Expression...'),
212
+ order: 'b'
213
+ });
214
+ menus.registerMenuAction(keybindings_widget_1.KeybindingWidget.ADD_MENU, {
215
+ commandId: KeymapsCommands.ADD_KEYBINDING.id,
216
+ label: nls_1.nls.localizeByDefault('Add Keybinding...'),
217
+ order: 'a'
218
+ });
219
+ menus.registerMenuAction(keybindings_widget_1.KeybindingWidget.REMOVE_MENU, {
220
+ commandId: KeymapsCommands.REMOVE_KEYBINDING.id,
221
+ label: nls_1.nls.localizeByDefault('Remove Keybinding'),
222
+ order: 'a'
223
+ });
224
+ menus.registerMenuAction(keybindings_widget_1.KeybindingWidget.REMOVE_MENU, {
225
+ commandId: KeymapsCommands.RESET_KEYBINDING.id,
226
+ label: nls_1.nls.localizeByDefault('Reset Keybinding'),
227
+ order: 'b'
228
+ });
229
+ menus.registerMenuAction(keybindings_widget_1.KeybindingWidget.SHOW_MENU, {
230
+ commandId: KeymapsCommands.SHOW_SAME.id,
231
+ label: nls_1.nls.localizeByDefault('Show Same Keybindings'),
232
+ order: 'a'
233
+ });
234
+ }
235
+ registerKeybindings(keybindings) {
236
+ keybindings.registerKeybinding({
237
+ command: KeymapsCommands.OPEN_KEYMAPS.id,
238
+ keybinding: 'ctrl+alt+,'
239
+ });
240
+ }
241
+ async registerToolbarItems(toolbar) {
242
+ const widget = await this.widget;
243
+ const onDidChange = widget.onDidUpdate;
244
+ toolbar.registerItem({
245
+ id: KeymapsCommands.OPEN_KEYMAPS_JSON_TOOLBAR.id,
246
+ command: KeymapsCommands.OPEN_KEYMAPS_JSON_TOOLBAR.id,
247
+ tooltip: nls_1.nls.localizeByDefault('Open Keyboard Shortcuts (JSON)'),
248
+ priority: 0,
249
+ });
250
+ toolbar.registerItem({
251
+ id: KeymapsCommands.CLEAR_KEYBINDINGS_SEARCH.id,
252
+ command: KeymapsCommands.CLEAR_KEYBINDINGS_SEARCH.id,
253
+ tooltip: nls_1.nls.localizeByDefault('Clear Keybindings Search Input'),
254
+ priority: 1,
255
+ onDidChange,
256
+ });
257
+ }
258
+ /**
259
+ * Determine if the current widget is the keybindings widget.
260
+ */
261
+ withWidget(widget = this.tryGetWidget(), fn) {
262
+ if (widget instanceof keybindings_widget_1.KeybindingWidget && widget.id === keybindings_widget_1.KeybindingWidget.ID) {
263
+ return fn(widget);
264
+ }
265
+ return false;
266
+ }
267
+ withItem(fn, ...args) {
268
+ const [item] = args;
269
+ if (keybindings_widget_1.KeybindingItem.is(item)) {
270
+ return fn(item, args.slice(1));
271
+ }
272
+ return false;
273
+ }
274
+ withWidgetItem(fn, ...args) {
275
+ const [item, widget] = args;
276
+ if (widget instanceof keybindings_widget_1.KeybindingWidget && widget.id === keybindings_widget_1.KeybindingWidget.ID && keybindings_widget_1.KeybindingItem.is(item)) {
277
+ return fn(item, widget, args.slice(2));
278
+ }
279
+ return false;
280
+ }
281
+ };
282
+ __decorate([
283
+ (0, inversify_1.inject)(keymaps_service_1.KeymapsService),
284
+ __metadata("design:type", keymaps_service_1.KeymapsService)
285
+ ], KeymapsFrontendContribution.prototype, "keymaps", void 0);
286
+ __decorate([
287
+ (0, inversify_1.inject)(clipboard_service_1.ClipboardService),
288
+ __metadata("design:type", Object)
289
+ ], KeymapsFrontendContribution.prototype, "clipboard", void 0);
290
+ KeymapsFrontendContribution = __decorate([
291
+ (0, inversify_1.injectable)(),
292
+ __metadata("design:paramtypes", [])
293
+ ], KeymapsFrontendContribution);
294
+ exports.KeymapsFrontendContribution = KeymapsFrontendContribution;
295
295
  //# sourceMappingURL=keymaps-frontend-contribution.js.map
@@ -1,6 +1,6 @@
1
- import './keymaps-monaco-contribution';
2
- import '../../src/browser/style/index.css';
3
- import { ContainerModule } from '@theia/core/shared/inversify';
4
- declare const _default: ContainerModule;
5
- export default _default;
1
+ import './keymaps-monaco-contribution';
2
+ import '../../src/browser/style/index.css';
3
+ import { ContainerModule } from '@theia/core/shared/inversify';
4
+ declare const _default: ContainerModule;
5
+ export default _default;
6
6
  //# sourceMappingURL=keymaps-frontend-module.d.ts.map