@theia/output 1.45.0 → 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.
Files changed (44) hide show
  1. package/README.md +33 -33
  2. package/lib/browser/output-channel.d.ts +125 -125
  3. package/lib/browser/output-channel.js +334 -334
  4. package/lib/browser/output-commands.d.ts +17 -17
  5. package/lib/browser/output-commands.js +84 -84
  6. package/lib/browser/output-context-menu.d.ts +11 -11
  7. package/lib/browser/output-context-menu.js +42 -42
  8. package/lib/browser/output-contribution.d.ts +29 -29
  9. package/lib/browser/output-contribution.js +284 -284
  10. package/lib/browser/output-editor-factory.d.ts +12 -12
  11. package/lib/browser/output-editor-factory.d.ts.map +1 -1
  12. package/lib/browser/output-editor-factory.js +79 -84
  13. package/lib/browser/output-editor-factory.js.map +1 -1
  14. package/lib/browser/output-editor-model-factory.d.ts +15 -15
  15. package/lib/browser/output-editor-model-factory.js +61 -61
  16. package/lib/browser/output-frontend-module.d.ts +3 -3
  17. package/lib/browser/output-frontend-module.js +50 -50
  18. package/lib/browser/output-preferences.d.ts +11 -11
  19. package/lib/browser/output-preferences.js +46 -46
  20. package/lib/browser/output-resource.d.ts +18 -18
  21. package/lib/browser/output-resource.js +54 -54
  22. package/lib/browser/output-toolbar-contribution.d.ts +21 -21
  23. package/lib/browser/output-toolbar-contribution.js +125 -125
  24. package/lib/browser/output-widget.d.ts +48 -48
  25. package/lib/browser/output-widget.js +248 -248
  26. package/lib/common/output-uri.d.ts +7 -7
  27. package/lib/common/output-uri.js +47 -47
  28. package/lib/common/output-uri.spec.d.ts +1 -1
  29. package/lib/common/output-uri.spec.js +50 -50
  30. package/package.json +7 -7
  31. package/src/browser/output-channel.ts +366 -366
  32. package/src/browser/output-commands.ts +100 -100
  33. package/src/browser/output-context-menu.ts +34 -34
  34. package/src/browser/output-contribution.ts +274 -274
  35. package/src/browser/output-editor-factory.ts +68 -74
  36. package/src/browser/output-editor-model-factory.ts +54 -54
  37. package/src/browser/output-frontend-module.ts +53 -53
  38. package/src/browser/output-preferences.ts +58 -58
  39. package/src/browser/output-resource.ts +65 -65
  40. package/src/browser/output-toolbar-contribution.tsx +116 -116
  41. package/src/browser/output-widget.ts +256 -256
  42. package/src/browser/style/output.css +31 -31
  43. package/src/common/output-uri.spec.ts +53 -53
  44. package/src/common/output-uri.ts +47 -47
@@ -1,274 +1,274 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2018 TypeFox and others.
3
- //
4
- // This program and the accompanying materials are made available under the
5
- // terms of the Eclipse Public License v. 2.0 which is available at
6
- // http://www.eclipse.org/legal/epl-2.0.
7
- //
8
- // This Source Code may also be made available under the following Secondary
9
- // Licenses when the conditions for such availability set forth in the Eclipse
10
- // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
- // with the GNU Classpath Exception which is available at
12
- // https://www.gnu.org/software/classpath/license.html.
13
- //
14
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
-
17
- import { injectable, inject, postConstruct } from '@theia/core/shared/inversify';
18
- import URI from '@theia/core/lib/common/uri';
19
- import { Widget } from '@theia/core/lib/browser/widgets/widget';
20
- import { MaybePromise } from '@theia/core/lib/common/types';
21
- import { CommonCommands, quickCommand, OpenHandler, open, OpenerOptions, OpenerService, QuickPickItem, QuickPickValue } from '@theia/core/lib/browser';
22
- import { CommandRegistry, MenuModelRegistry, CommandService } from '@theia/core/lib/common';
23
- import { AbstractViewContribution } from '@theia/core/lib/browser/shell/view-contribution';
24
- import { OutputWidget } from './output-widget';
25
- import { OutputContextMenu } from './output-context-menu';
26
- import { OutputUri } from '../common/output-uri';
27
- import { ClipboardService } from '@theia/core/lib/browser/clipboard-service';
28
- import { OutputChannelManager, OutputChannel } from './output-channel';
29
- import { OutputCommands } from './output-commands';
30
- import { QuickPickSeparator, QuickPickService } from '@theia/core/lib/common/quick-pick-service';
31
- import { nls } from '@theia/core/lib/common/nls';
32
-
33
- @injectable()
34
- export class OutputContribution extends AbstractViewContribution<OutputWidget> implements OpenHandler {
35
-
36
- @inject(ClipboardService)
37
- protected readonly clipboardService: ClipboardService;
38
-
39
- @inject(CommandService)
40
- protected readonly commandService: CommandService;
41
-
42
- @inject(OutputChannelManager)
43
- protected readonly outputChannelManager: OutputChannelManager;
44
-
45
- @inject(OpenerService)
46
- protected readonly openerService: OpenerService;
47
-
48
- @inject(QuickPickService)
49
- protected readonly quickPickService: QuickPickService;
50
-
51
- readonly id: string = `${OutputWidget.ID}-opener`;
52
-
53
- constructor() {
54
- super({
55
- widgetId: OutputWidget.ID,
56
- widgetName: OutputWidget.LABEL,
57
- defaultWidgetOptions: {
58
- area: 'bottom'
59
- },
60
- toggleCommandId: 'output:toggle',
61
- toggleKeybinding: 'CtrlCmd+Shift+U'
62
- });
63
- }
64
-
65
- @postConstruct()
66
- protected init(): void {
67
- this.outputChannelManager.onChannelWasShown(({ name, preserveFocus }) =>
68
- open(this.openerService, OutputUri.create(name), { activate: !preserveFocus, reveal: true }));
69
- }
70
-
71
- override registerCommands(registry: CommandRegistry): void {
72
- super.registerCommands(registry);
73
- registry.registerCommand(OutputCommands.CLEAR__WIDGET, {
74
- isEnabled: arg => {
75
- if (arg instanceof Widget) {
76
- return arg instanceof OutputWidget;
77
- }
78
- return this.shell.currentWidget instanceof OutputWidget;
79
- },
80
- isVisible: arg => {
81
- if (arg instanceof Widget) {
82
- return arg instanceof OutputWidget;
83
- }
84
- return this.shell.currentWidget instanceof OutputWidget;
85
- },
86
- execute: () => {
87
- this.widget.then(widget => {
88
- this.withWidget(widget, output => {
89
- output.clear();
90
- return true;
91
- });
92
- });
93
- }
94
- });
95
- registry.registerCommand(OutputCommands.LOCK__WIDGET, {
96
- isEnabled: widget => this.withWidget(widget, output => !output.isLocked),
97
- isVisible: widget => this.withWidget(widget, output => !output.isLocked),
98
- execute: widget => this.withWidget(widget, output => {
99
- output.lock();
100
- return true;
101
- })
102
- });
103
- registry.registerCommand(OutputCommands.UNLOCK__WIDGET, {
104
- isEnabled: widget => this.withWidget(widget, output => output.isLocked),
105
- isVisible: widget => this.withWidget(widget, output => output.isLocked),
106
- execute: widget => this.withWidget(widget, output => {
107
- output.unlock();
108
- return true;
109
- })
110
- });
111
- registry.registerCommand(OutputCommands.COPY_ALL, {
112
- execute: () => {
113
- const textToCopy = this.tryGetWidget()?.getText();
114
- if (textToCopy) {
115
- this.clipboardService.writeText(textToCopy);
116
- }
117
- }
118
- });
119
- registry.registerCommand(OutputCommands.APPEND, {
120
- execute: ({ name, text }: { name: string, text: string }) => {
121
- if (name && text) {
122
- this.outputChannelManager.getChannel(name).append(text);
123
- }
124
- }
125
- });
126
- registry.registerCommand(OutputCommands.APPEND_LINE, {
127
- execute: ({ name, text }: { name: string, text: string }) => {
128
- if (name && text) {
129
- this.outputChannelManager.getChannel(name).appendLine(text);
130
- }
131
- }
132
- });
133
- registry.registerCommand(OutputCommands.CLEAR, {
134
- execute: ({ name }: { name: string }) => {
135
- if (name) {
136
- this.outputChannelManager.getChannel(name).clear();
137
- }
138
- }
139
- });
140
- registry.registerCommand(OutputCommands.DISPOSE, {
141
- execute: ({ name }: { name: string }) => {
142
- if (name) {
143
- this.outputChannelManager.deleteChannel(name);
144
- }
145
- }
146
- });
147
- registry.registerCommand(OutputCommands.SHOW, {
148
- execute: ({ name, options }: { name: string, options?: { preserveFocus?: boolean } }) => {
149
- if (name) {
150
- const preserveFocus = options && options.preserveFocus || false;
151
- this.outputChannelManager.getChannel(name).show({ preserveFocus });
152
- }
153
- }
154
- });
155
- registry.registerCommand(OutputCommands.HIDE, {
156
- execute: ({ name }: { name: string }) => {
157
- if (name) {
158
- this.outputChannelManager.getChannel(name).hide();
159
- }
160
- }
161
- });
162
-
163
- registry.registerCommand(OutputCommands.CLEAR__QUICK_PICK, {
164
- execute: async () => {
165
- const channel = await this.pick({
166
- placeholder: OutputCommands.CLEAR__QUICK_PICK.label!,
167
- channels: this.outputChannelManager.getChannels().slice()
168
- });
169
- if (channel) {
170
- channel.clear();
171
- }
172
- },
173
- isEnabled: () => !!this.outputChannelManager.getChannels().length,
174
- isVisible: () => !!this.outputChannelManager.getChannels().length
175
- });
176
- registry.registerCommand(OutputCommands.SHOW__QUICK_PICK, {
177
- execute: async () => {
178
- const channel = await this.pick({
179
- placeholder: OutputCommands.SHOW__QUICK_PICK.label!,
180
- channels: this.outputChannelManager.getChannels().slice()
181
- });
182
- if (channel) {
183
- const { name } = channel;
184
- registry.executeCommand(OutputCommands.SHOW.id, { name, options: { preserveFocus: false } });
185
- }
186
- },
187
- isEnabled: () => !!this.outputChannelManager.getChannels().length,
188
- isVisible: () => !!this.outputChannelManager.getChannels().length
189
- });
190
- registry.registerCommand(OutputCommands.HIDE__QUICK_PICK, {
191
- execute: async () => {
192
- const channel = await this.pick({
193
- placeholder: OutputCommands.HIDE__QUICK_PICK.label!,
194
- channels: this.outputChannelManager.getVisibleChannels().slice()
195
- });
196
- if (channel) {
197
- const { name } = channel;
198
- registry.executeCommand(OutputCommands.HIDE.id, { name });
199
- }
200
- },
201
- isEnabled: () => !!this.outputChannelManager.getVisibleChannels().length,
202
- isVisible: () => !!this.outputChannelManager.getVisibleChannels().length
203
- });
204
- registry.registerCommand(OutputCommands.DISPOSE__QUICK_PICK, {
205
- execute: async () => {
206
- const channel = await this.pick({
207
- placeholder: OutputCommands.DISPOSE__QUICK_PICK.label!,
208
- channels: this.outputChannelManager.getChannels().slice()
209
- });
210
- if (channel) {
211
- const { name } = channel;
212
- registry.executeCommand(OutputCommands.DISPOSE.id, { name });
213
- }
214
- },
215
- isEnabled: () => !!this.outputChannelManager.getChannels().length,
216
- isVisible: () => !!this.outputChannelManager.getChannels().length
217
- });
218
- }
219
-
220
- override registerMenus(registry: MenuModelRegistry): void {
221
- super.registerMenus(registry);
222
- registry.registerMenuAction(OutputContextMenu.TEXT_EDIT_GROUP, {
223
- commandId: CommonCommands.COPY.id
224
- });
225
- registry.registerMenuAction(OutputContextMenu.TEXT_EDIT_GROUP, {
226
- commandId: OutputCommands.COPY_ALL.id,
227
- label: nls.localizeByDefault('Copy All')
228
- });
229
- registry.registerMenuAction(OutputContextMenu.COMMAND_GROUP, {
230
- commandId: quickCommand.id,
231
- label: nls.localizeByDefault('Command Palette...')
232
- });
233
- registry.registerMenuAction(OutputContextMenu.WIDGET_GROUP, {
234
- commandId: OutputCommands.CLEAR__WIDGET.id,
235
- label: nls.localizeByDefault('Clear Output')
236
- });
237
- }
238
-
239
- canHandle(uri: URI): MaybePromise<number> {
240
- return OutputUri.is(uri) ? 200 : 0;
241
- }
242
-
243
- async open(uri: URI, options?: OpenerOptions): Promise<OutputWidget> {
244
- if (!OutputUri.is(uri)) {
245
- throw new Error(`Expected '${OutputUri.SCHEME}' URI scheme. Got: ${uri} instead.`);
246
- }
247
- const widget = await this.openView(options);
248
- return widget;
249
- }
250
-
251
- protected withWidget(
252
- widget: Widget | undefined = this.tryGetWidget(),
253
- predicate: (output: OutputWidget) => boolean = () => true
254
- ): boolean | false {
255
- return widget instanceof OutputWidget ? predicate(widget) : false;
256
- }
257
-
258
- protected async pick({ channels, placeholder }: { channels: OutputChannel[], placeholder: string }): Promise<OutputChannel | undefined> {
259
- const items: Array<QuickPickValue<OutputChannel> | QuickPickItem | QuickPickSeparator> = [];
260
- const outputChannels = nls.localize('theia/output/outputChannels', 'Output Channels');
261
- const hiddenChannels = nls.localize('theia/output/hiddenChannels', 'Hidden Channels');
262
- for (let i = 0; i < channels.length; i++) {
263
- const channel = channels[i];
264
- if (i === 0) {
265
- items.push({ label: channel.isVisible ? outputChannels : hiddenChannels, type: 'separator' });
266
- } else if (!channel.isVisible && channels[i - 1].isVisible) {
267
- items.push({ label: hiddenChannels, type: 'separator' });
268
- }
269
- items.push({ label: channel.name, value: channel });
270
- }
271
- const selectedItem = await this.quickPickService.show(items, { placeholder });
272
- return selectedItem && ('value' in selectedItem) ? selectedItem.value : undefined;
273
- }
274
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2018 TypeFox and others.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { injectable, inject, postConstruct } from '@theia/core/shared/inversify';
18
+ import URI from '@theia/core/lib/common/uri';
19
+ import { Widget } from '@theia/core/lib/browser/widgets/widget';
20
+ import { MaybePromise } from '@theia/core/lib/common/types';
21
+ import { CommonCommands, quickCommand, OpenHandler, open, OpenerOptions, OpenerService, QuickPickItem, QuickPickValue } from '@theia/core/lib/browser';
22
+ import { CommandRegistry, MenuModelRegistry, CommandService } from '@theia/core/lib/common';
23
+ import { AbstractViewContribution } from '@theia/core/lib/browser/shell/view-contribution';
24
+ import { OutputWidget } from './output-widget';
25
+ import { OutputContextMenu } from './output-context-menu';
26
+ import { OutputUri } from '../common/output-uri';
27
+ import { ClipboardService } from '@theia/core/lib/browser/clipboard-service';
28
+ import { OutputChannelManager, OutputChannel } from './output-channel';
29
+ import { OutputCommands } from './output-commands';
30
+ import { QuickPickSeparator, QuickPickService } from '@theia/core/lib/common/quick-pick-service';
31
+ import { nls } from '@theia/core/lib/common/nls';
32
+
33
+ @injectable()
34
+ export class OutputContribution extends AbstractViewContribution<OutputWidget> implements OpenHandler {
35
+
36
+ @inject(ClipboardService)
37
+ protected readonly clipboardService: ClipboardService;
38
+
39
+ @inject(CommandService)
40
+ protected readonly commandService: CommandService;
41
+
42
+ @inject(OutputChannelManager)
43
+ protected readonly outputChannelManager: OutputChannelManager;
44
+
45
+ @inject(OpenerService)
46
+ protected readonly openerService: OpenerService;
47
+
48
+ @inject(QuickPickService)
49
+ protected readonly quickPickService: QuickPickService;
50
+
51
+ readonly id: string = `${OutputWidget.ID}-opener`;
52
+
53
+ constructor() {
54
+ super({
55
+ widgetId: OutputWidget.ID,
56
+ widgetName: OutputWidget.LABEL,
57
+ defaultWidgetOptions: {
58
+ area: 'bottom'
59
+ },
60
+ toggleCommandId: 'output:toggle',
61
+ toggleKeybinding: 'CtrlCmd+Shift+U'
62
+ });
63
+ }
64
+
65
+ @postConstruct()
66
+ protected init(): void {
67
+ this.outputChannelManager.onChannelWasShown(({ name, preserveFocus }) =>
68
+ open(this.openerService, OutputUri.create(name), { activate: !preserveFocus, reveal: true }));
69
+ }
70
+
71
+ override registerCommands(registry: CommandRegistry): void {
72
+ super.registerCommands(registry);
73
+ registry.registerCommand(OutputCommands.CLEAR__WIDGET, {
74
+ isEnabled: arg => {
75
+ if (arg instanceof Widget) {
76
+ return arg instanceof OutputWidget;
77
+ }
78
+ return this.shell.currentWidget instanceof OutputWidget;
79
+ },
80
+ isVisible: arg => {
81
+ if (arg instanceof Widget) {
82
+ return arg instanceof OutputWidget;
83
+ }
84
+ return this.shell.currentWidget instanceof OutputWidget;
85
+ },
86
+ execute: () => {
87
+ this.widget.then(widget => {
88
+ this.withWidget(widget, output => {
89
+ output.clear();
90
+ return true;
91
+ });
92
+ });
93
+ }
94
+ });
95
+ registry.registerCommand(OutputCommands.LOCK__WIDGET, {
96
+ isEnabled: widget => this.withWidget(widget, output => !output.isLocked),
97
+ isVisible: widget => this.withWidget(widget, output => !output.isLocked),
98
+ execute: widget => this.withWidget(widget, output => {
99
+ output.lock();
100
+ return true;
101
+ })
102
+ });
103
+ registry.registerCommand(OutputCommands.UNLOCK__WIDGET, {
104
+ isEnabled: widget => this.withWidget(widget, output => output.isLocked),
105
+ isVisible: widget => this.withWidget(widget, output => output.isLocked),
106
+ execute: widget => this.withWidget(widget, output => {
107
+ output.unlock();
108
+ return true;
109
+ })
110
+ });
111
+ registry.registerCommand(OutputCommands.COPY_ALL, {
112
+ execute: () => {
113
+ const textToCopy = this.tryGetWidget()?.getText();
114
+ if (textToCopy) {
115
+ this.clipboardService.writeText(textToCopy);
116
+ }
117
+ }
118
+ });
119
+ registry.registerCommand(OutputCommands.APPEND, {
120
+ execute: ({ name, text }: { name: string, text: string }) => {
121
+ if (name && text) {
122
+ this.outputChannelManager.getChannel(name).append(text);
123
+ }
124
+ }
125
+ });
126
+ registry.registerCommand(OutputCommands.APPEND_LINE, {
127
+ execute: ({ name, text }: { name: string, text: string }) => {
128
+ if (name && text) {
129
+ this.outputChannelManager.getChannel(name).appendLine(text);
130
+ }
131
+ }
132
+ });
133
+ registry.registerCommand(OutputCommands.CLEAR, {
134
+ execute: ({ name }: { name: string }) => {
135
+ if (name) {
136
+ this.outputChannelManager.getChannel(name).clear();
137
+ }
138
+ }
139
+ });
140
+ registry.registerCommand(OutputCommands.DISPOSE, {
141
+ execute: ({ name }: { name: string }) => {
142
+ if (name) {
143
+ this.outputChannelManager.deleteChannel(name);
144
+ }
145
+ }
146
+ });
147
+ registry.registerCommand(OutputCommands.SHOW, {
148
+ execute: ({ name, options }: { name: string, options?: { preserveFocus?: boolean } }) => {
149
+ if (name) {
150
+ const preserveFocus = options && options.preserveFocus || false;
151
+ this.outputChannelManager.getChannel(name).show({ preserveFocus });
152
+ }
153
+ }
154
+ });
155
+ registry.registerCommand(OutputCommands.HIDE, {
156
+ execute: ({ name }: { name: string }) => {
157
+ if (name) {
158
+ this.outputChannelManager.getChannel(name).hide();
159
+ }
160
+ }
161
+ });
162
+
163
+ registry.registerCommand(OutputCommands.CLEAR__QUICK_PICK, {
164
+ execute: async () => {
165
+ const channel = await this.pick({
166
+ placeholder: OutputCommands.CLEAR__QUICK_PICK.label!,
167
+ channels: this.outputChannelManager.getChannels().slice()
168
+ });
169
+ if (channel) {
170
+ channel.clear();
171
+ }
172
+ },
173
+ isEnabled: () => !!this.outputChannelManager.getChannels().length,
174
+ isVisible: () => !!this.outputChannelManager.getChannels().length
175
+ });
176
+ registry.registerCommand(OutputCommands.SHOW__QUICK_PICK, {
177
+ execute: async () => {
178
+ const channel = await this.pick({
179
+ placeholder: OutputCommands.SHOW__QUICK_PICK.label!,
180
+ channels: this.outputChannelManager.getChannels().slice()
181
+ });
182
+ if (channel) {
183
+ const { name } = channel;
184
+ registry.executeCommand(OutputCommands.SHOW.id, { name, options: { preserveFocus: false } });
185
+ }
186
+ },
187
+ isEnabled: () => !!this.outputChannelManager.getChannels().length,
188
+ isVisible: () => !!this.outputChannelManager.getChannels().length
189
+ });
190
+ registry.registerCommand(OutputCommands.HIDE__QUICK_PICK, {
191
+ execute: async () => {
192
+ const channel = await this.pick({
193
+ placeholder: OutputCommands.HIDE__QUICK_PICK.label!,
194
+ channels: this.outputChannelManager.getVisibleChannels().slice()
195
+ });
196
+ if (channel) {
197
+ const { name } = channel;
198
+ registry.executeCommand(OutputCommands.HIDE.id, { name });
199
+ }
200
+ },
201
+ isEnabled: () => !!this.outputChannelManager.getVisibleChannels().length,
202
+ isVisible: () => !!this.outputChannelManager.getVisibleChannels().length
203
+ });
204
+ registry.registerCommand(OutputCommands.DISPOSE__QUICK_PICK, {
205
+ execute: async () => {
206
+ const channel = await this.pick({
207
+ placeholder: OutputCommands.DISPOSE__QUICK_PICK.label!,
208
+ channels: this.outputChannelManager.getChannels().slice()
209
+ });
210
+ if (channel) {
211
+ const { name } = channel;
212
+ registry.executeCommand(OutputCommands.DISPOSE.id, { name });
213
+ }
214
+ },
215
+ isEnabled: () => !!this.outputChannelManager.getChannels().length,
216
+ isVisible: () => !!this.outputChannelManager.getChannels().length
217
+ });
218
+ }
219
+
220
+ override registerMenus(registry: MenuModelRegistry): void {
221
+ super.registerMenus(registry);
222
+ registry.registerMenuAction(OutputContextMenu.TEXT_EDIT_GROUP, {
223
+ commandId: CommonCommands.COPY.id
224
+ });
225
+ registry.registerMenuAction(OutputContextMenu.TEXT_EDIT_GROUP, {
226
+ commandId: OutputCommands.COPY_ALL.id,
227
+ label: nls.localizeByDefault('Copy All')
228
+ });
229
+ registry.registerMenuAction(OutputContextMenu.COMMAND_GROUP, {
230
+ commandId: quickCommand.id,
231
+ label: nls.localizeByDefault('Command Palette...')
232
+ });
233
+ registry.registerMenuAction(OutputContextMenu.WIDGET_GROUP, {
234
+ commandId: OutputCommands.CLEAR__WIDGET.id,
235
+ label: nls.localizeByDefault('Clear Output')
236
+ });
237
+ }
238
+
239
+ canHandle(uri: URI): MaybePromise<number> {
240
+ return OutputUri.is(uri) ? 200 : 0;
241
+ }
242
+
243
+ async open(uri: URI, options?: OpenerOptions): Promise<OutputWidget> {
244
+ if (!OutputUri.is(uri)) {
245
+ throw new Error(`Expected '${OutputUri.SCHEME}' URI scheme. Got: ${uri} instead.`);
246
+ }
247
+ const widget = await this.openView(options);
248
+ return widget;
249
+ }
250
+
251
+ protected withWidget(
252
+ widget: Widget | undefined = this.tryGetWidget(),
253
+ predicate: (output: OutputWidget) => boolean = () => true
254
+ ): boolean | false {
255
+ return widget instanceof OutputWidget ? predicate(widget) : false;
256
+ }
257
+
258
+ protected async pick({ channels, placeholder }: { channels: OutputChannel[], placeholder: string }): Promise<OutputChannel | undefined> {
259
+ const items: Array<QuickPickValue<OutputChannel> | QuickPickItem | QuickPickSeparator> = [];
260
+ const outputChannels = nls.localize('theia/output/outputChannels', 'Output Channels');
261
+ const hiddenChannels = nls.localize('theia/output/hiddenChannels', 'Hidden Channels');
262
+ for (let i = 0; i < channels.length; i++) {
263
+ const channel = channels[i];
264
+ if (i === 0) {
265
+ items.push({ label: channel.isVisible ? outputChannels : hiddenChannels, type: 'separator' });
266
+ } else if (!channel.isVisible && channels[i - 1].isVisible) {
267
+ items.push({ label: hiddenChannels, type: 'separator' });
268
+ }
269
+ items.push({ label: channel.name, value: channel });
270
+ }
271
+ const selectedItem = await this.quickPickService.show(items, { placeholder });
272
+ return selectedItem && ('value' in selectedItem) ? selectedItem.value : undefined;
273
+ }
274
+ }