@theia/console 1.53.0-next.4 → 1.53.0-next.55

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/README.md CHANGED
@@ -1,30 +1,30 @@
1
- <div align='center'>
2
-
3
- <br />
4
-
5
- <img src='https://raw.githubusercontent.com/eclipse-theia/theia/master/logo/theia.svg?sanitize=true' alt='theia-ext-logo' width='100px' />
6
-
7
- <h2>ECLIPSE THEIA - CONSOLE EXTENSION</h2>
8
-
9
- <hr />
10
-
11
- </div>
12
-
13
- ## Description
14
-
15
- The `@theia/console` extension contributes a `console` widget which is used to evaluate expressions (in the form of REPL [(Read-Eval-Print-Loop)](https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop)) when debugging.
16
-
17
- ## Additional Information
18
-
19
- - [API documentation for `@theia/console`](https://eclipse-theia.github.io/theia/docs/next/modules/console.html)
20
- - [Theia - GitHub](https://github.com/eclipse-theia/theia)
21
- - [Theia - Website](https://theia-ide.org/)
22
-
23
- ## License
24
-
25
- - [Eclipse Public License 2.0](http://www.eclipse.org/legal/epl-2.0/)
26
- - [一 (Secondary) GNU General Public License, version 2 with the GNU Classpath Exception](https://projects.eclipse.org/license/secondary-gpl-2.0-cp)
27
-
28
- ## Trademark
29
- "Theia" is a trademark of the Eclipse Foundation
30
- https://www.eclipse.org/theia
1
+ <div align='center'>
2
+
3
+ <br />
4
+
5
+ <img src='https://raw.githubusercontent.com/eclipse-theia/theia/master/logo/theia.svg?sanitize=true' alt='theia-ext-logo' width='100px' />
6
+
7
+ <h2>ECLIPSE THEIA - CONSOLE EXTENSION</h2>
8
+
9
+ <hr />
10
+
11
+ </div>
12
+
13
+ ## Description
14
+
15
+ The `@theia/console` extension contributes a `console` widget which is used to evaluate expressions (in the form of REPL [(Read-Eval-Print-Loop)](https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop)) when debugging.
16
+
17
+ ## Additional Information
18
+
19
+ - [API documentation for `@theia/console`](https://eclipse-theia.github.io/theia/docs/next/modules/console.html)
20
+ - [Theia - GitHub](https://github.com/eclipse-theia/theia)
21
+ - [Theia - Website](https://theia-ide.org/)
22
+
23
+ ## License
24
+
25
+ - [Eclipse Public License 2.0](http://www.eclipse.org/legal/epl-2.0/)
26
+ - [一 (Secondary) GNU General Public License, version 2 with the GNU Classpath Exception](https://projects.eclipse.org/license/secondary-gpl-2.0-cp)
27
+
28
+ ## Trademark
29
+ "Theia" is a trademark of the Eclipse Foundation
30
+ https://www.eclipse.org/theia
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@theia/console",
3
- "version": "1.53.0-next.4+9e9124118",
3
+ "version": "1.53.0-next.55+d1a989a68c",
4
4
  "description": "Theia - Console Extension",
5
5
  "dependencies": {
6
- "@theia/core": "1.53.0-next.4+9e9124118",
7
- "@theia/monaco": "1.53.0-next.4+9e9124118",
6
+ "@theia/core": "1.53.0-next.55+d1a989a68c",
7
+ "@theia/monaco": "1.53.0-next.55+d1a989a68c",
8
8
  "@theia/monaco-editor-core": "1.83.101",
9
9
  "anser": "^2.0.1",
10
10
  "tslib": "^2.6.2"
@@ -42,10 +42,10 @@
42
42
  "watch": "theiaext watch"
43
43
  },
44
44
  "devDependencies": {
45
- "@theia/ext-scripts": "1.52.0"
45
+ "@theia/ext-scripts": "1.53.0"
46
46
  },
47
47
  "nyc": {
48
48
  "extends": "../../configs/nyc.json"
49
49
  },
50
- "gitHead": "9e912411843f32b2a549ef6580b07872edd95e8b"
50
+ "gitHead": "d1a989a68c1b5ec1f9098e9126653c6346844769"
51
51
  }
@@ -1,48 +1,48 @@
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 * as React from '@theia/core/shared/react';
18
- import * as DOMPurify from '@theia/core/shared/dompurify';
19
- import { ConsoleItem } from './console-session';
20
- import { Severity } from '@theia/core/lib/common/severity';
21
- import Anser = require('anser');
22
-
23
- export class AnsiConsoleItem implements ConsoleItem {
24
-
25
- protected readonly htmlContent: string;
26
-
27
- constructor(
28
- public readonly content: string,
29
- public readonly severity?: Severity
30
- ) {
31
- this.htmlContent = new Anser().ansiToHtml(this.content, {
32
- use_classes: true,
33
- remove_empty: true
34
- });
35
- }
36
-
37
- get visible(): boolean {
38
- return !!this.htmlContent;
39
- }
40
-
41
- render(): React.ReactNode {
42
- return <div
43
- className='theia-console-ansi-console-item'
44
- dangerouslySetInnerHTML={{ __html: DOMPurify.sanitize(this.htmlContent) }} // eslint-disable-line react/no-danger
45
- />;
46
- }
47
-
48
- }
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 * as React from '@theia/core/shared/react';
18
+ import * as DOMPurify from '@theia/core/shared/dompurify';
19
+ import { ConsoleItem } from './console-session';
20
+ import { Severity } from '@theia/core/lib/common/severity';
21
+ import Anser = require('anser');
22
+
23
+ export class AnsiConsoleItem implements ConsoleItem {
24
+
25
+ protected readonly htmlContent: string;
26
+
27
+ constructor(
28
+ public readonly content: string,
29
+ public readonly severity?: Severity
30
+ ) {
31
+ this.htmlContent = new Anser().ansiToHtml(this.content, {
32
+ use_classes: true,
33
+ remove_empty: true
34
+ });
35
+ }
36
+
37
+ get visible(): boolean {
38
+ return !!this.htmlContent;
39
+ }
40
+
41
+ render(): React.ReactNode {
42
+ return <div
43
+ className='theia-console-ansi-console-item'
44
+ dangerouslySetInnerHTML={{ __html: DOMPurify.sanitize(this.htmlContent) }} // eslint-disable-line react/no-danger
45
+ />;
46
+ }
47
+
48
+ }
@@ -1,91 +1,91 @@
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 { Message } from '@theia/core/shared/@phosphor/messaging';
18
- import { interfaces, Container, injectable } from '@theia/core/shared/inversify';
19
- import { MenuPath } from '@theia/core';
20
- import { TreeProps } from '@theia/core/lib/browser/tree';
21
- import { SourceTreeWidget, TreeSourceNode, TreeElementNode } from '@theia/core/lib/browser/source-tree';
22
- import { ConsoleItem } from './console-session';
23
- import { Severity } from '@theia/core/lib/common/severity';
24
-
25
- @injectable()
26
- export class ConsoleContentWidget extends SourceTreeWidget {
27
-
28
- static CONTEXT_MENU: MenuPath = ['console-context-menu'];
29
-
30
- protected _shouldScrollToEnd = true;
31
-
32
- protected set shouldScrollToEnd(shouldScrollToEnd: boolean) {
33
- this._shouldScrollToEnd = shouldScrollToEnd;
34
- this.shouldScrollToRow = this._shouldScrollToEnd;
35
- }
36
-
37
- protected get shouldScrollToEnd(): boolean {
38
- return this._shouldScrollToEnd;
39
- }
40
-
41
- static override createContainer(parent: interfaces.Container, props?: Partial<TreeProps>): Container {
42
- const child = SourceTreeWidget.createContainer(parent, {
43
- contextMenuPath: ConsoleContentWidget.CONTEXT_MENU,
44
- ...props
45
- });
46
- child.unbind(SourceTreeWidget);
47
- child.bind(ConsoleContentWidget).toSelf();
48
- return child;
49
- }
50
-
51
- protected override onAfterAttach(msg: Message): void {
52
- super.onAfterAttach(msg);
53
- this.toDisposeOnDetach.push(this.onScrollUp(() => this.shouldScrollToEnd = false));
54
- this.toDisposeOnDetach.push(this.onScrollYReachEnd(() => this.shouldScrollToEnd = true));
55
- this.toDisposeOnDetach.push(this.model.onChanged(() => this.revealLastOutputIfNeeded()));
56
- }
57
-
58
- protected revealLastOutputIfNeeded(): void {
59
- const { root } = this.model;
60
- if (this.shouldScrollToEnd && TreeSourceNode.is(root)) {
61
- this.model.selectNode(root.children[root.children.length - 1]);
62
- }
63
- }
64
-
65
- protected override createTreeElementNodeClassNames(node: TreeElementNode): string[] {
66
- const classNames = super.createTreeElementNodeClassNames(node);
67
- if (node.element) {
68
- const className = this.toClassName((node.element as ConsoleItem));
69
- if (className) {
70
- classNames.push(className);
71
- }
72
- }
73
- return classNames;
74
- }
75
- protected toClassName(item: ConsoleItem): string | undefined {
76
- if (item.severity === Severity.Error) {
77
- return ConsoleItem.errorClassName;
78
- }
79
- if (item.severity === Severity.Warning) {
80
- return ConsoleItem.warningClassName;
81
- }
82
- if (item.severity === Severity.Info) {
83
- return ConsoleItem.infoClassName;
84
- }
85
- if (item.severity === Severity.Log) {
86
- return ConsoleItem.logClassName;
87
- }
88
- return undefined;
89
- }
90
-
91
- }
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 { Message } from '@theia/core/shared/@phosphor/messaging';
18
+ import { interfaces, Container, injectable } from '@theia/core/shared/inversify';
19
+ import { MenuPath } from '@theia/core';
20
+ import { TreeProps } from '@theia/core/lib/browser/tree';
21
+ import { SourceTreeWidget, TreeSourceNode, TreeElementNode } from '@theia/core/lib/browser/source-tree';
22
+ import { ConsoleItem } from './console-session';
23
+ import { Severity } from '@theia/core/lib/common/severity';
24
+
25
+ @injectable()
26
+ export class ConsoleContentWidget extends SourceTreeWidget {
27
+
28
+ static CONTEXT_MENU: MenuPath = ['console-context-menu'];
29
+
30
+ protected _shouldScrollToEnd = true;
31
+
32
+ protected set shouldScrollToEnd(shouldScrollToEnd: boolean) {
33
+ this._shouldScrollToEnd = shouldScrollToEnd;
34
+ this.shouldScrollToRow = this._shouldScrollToEnd;
35
+ }
36
+
37
+ protected get shouldScrollToEnd(): boolean {
38
+ return this._shouldScrollToEnd;
39
+ }
40
+
41
+ static override createContainer(parent: interfaces.Container, props?: Partial<TreeProps>): Container {
42
+ const child = SourceTreeWidget.createContainer(parent, {
43
+ contextMenuPath: ConsoleContentWidget.CONTEXT_MENU,
44
+ ...props
45
+ });
46
+ child.unbind(SourceTreeWidget);
47
+ child.bind(ConsoleContentWidget).toSelf();
48
+ return child;
49
+ }
50
+
51
+ protected override onAfterAttach(msg: Message): void {
52
+ super.onAfterAttach(msg);
53
+ this.toDisposeOnDetach.push(this.onScrollUp(() => this.shouldScrollToEnd = false));
54
+ this.toDisposeOnDetach.push(this.onScrollYReachEnd(() => this.shouldScrollToEnd = true));
55
+ this.toDisposeOnDetach.push(this.model.onChanged(() => this.revealLastOutputIfNeeded()));
56
+ }
57
+
58
+ protected revealLastOutputIfNeeded(): void {
59
+ const { root } = this.model;
60
+ if (this.shouldScrollToEnd && TreeSourceNode.is(root)) {
61
+ this.model.selectNode(root.children[root.children.length - 1]);
62
+ }
63
+ }
64
+
65
+ protected override createTreeElementNodeClassNames(node: TreeElementNode): string[] {
66
+ const classNames = super.createTreeElementNodeClassNames(node);
67
+ if (node.element) {
68
+ const className = this.toClassName((node.element as ConsoleItem));
69
+ if (className) {
70
+ classNames.push(className);
71
+ }
72
+ }
73
+ return classNames;
74
+ }
75
+ protected toClassName(item: ConsoleItem): string | undefined {
76
+ if (item.severity === Severity.Error) {
77
+ return ConsoleItem.errorClassName;
78
+ }
79
+ if (item.severity === Severity.Warning) {
80
+ return ConsoleItem.warningClassName;
81
+ }
82
+ if (item.severity === Severity.Info) {
83
+ return ConsoleItem.infoClassName;
84
+ }
85
+ if (item.severity === Severity.Log) {
86
+ return ConsoleItem.logClassName;
87
+ }
88
+ return undefined;
89
+ }
90
+
91
+ }
@@ -1,143 +1,143 @@
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 } from '@theia/core/shared/inversify';
18
- import { Command, CommandContribution, CommandRegistry, MenuContribution, MenuModelRegistry, CommandHandler } from '@theia/core';
19
- import { FrontendApplicationContribution, KeybindingContribution, KeybindingRegistry, CommonCommands } from '@theia/core/lib/browser';
20
- import { ConsoleManager } from './console-manager';
21
- import { ConsoleWidget } from './console-widget';
22
- import { ConsoleContentWidget } from './console-content-widget';
23
- import { nls } from '@theia/core/lib/common/nls';
24
-
25
- export namespace ConsoleCommands {
26
- export const SELECT_ALL: Command = {
27
- id: 'console.selectAll'
28
- };
29
- export const COLLAPSE_ALL: Command = {
30
- id: 'console.collapseAll'
31
- };
32
- export const CLEAR: Command = {
33
- id: 'console.clear'
34
- };
35
- export const EXECUTE: Command = {
36
- id: 'console.execute'
37
- };
38
- export const NAVIGATE_BACK: Command = {
39
- id: 'console.navigatePrevious'
40
- };
41
- export const NAVIGATE_FORWARD: Command = {
42
- id: 'console.navigateNext'
43
- };
44
- }
45
-
46
- export namespace ConsoleContextMenu {
47
- export const CLIPBOARD = [...ConsoleContentWidget.CONTEXT_MENU, '1_clipboard'];
48
- export const CLEAR = [...ConsoleContentWidget.CONTEXT_MENU, '2_clear'];
49
- }
50
-
51
- @injectable()
52
- export class ConsoleContribution implements FrontendApplicationContribution, CommandContribution, KeybindingContribution, MenuContribution {
53
-
54
- @inject(ConsoleManager)
55
- protected readonly manager: ConsoleManager;
56
-
57
- initialize(): void { }
58
-
59
- registerCommands(commands: CommandRegistry): void {
60
- commands.registerCommand(ConsoleCommands.SELECT_ALL, this.newCommandHandler(console => console.selectAll()));
61
- commands.registerCommand(ConsoleCommands.COLLAPSE_ALL, this.newCommandHandler(console => console.collapseAll()));
62
- commands.registerCommand(ConsoleCommands.CLEAR, this.newCommandHandler(console => console.clear()));
63
- commands.registerCommand(ConsoleCommands.EXECUTE, this.newCommandHandler(console => console.execute()));
64
- commands.registerCommand(ConsoleCommands.NAVIGATE_BACK, this.newCommandHandler(console => console.navigateBack()));
65
- commands.registerCommand(ConsoleCommands.NAVIGATE_FORWARD, this.newCommandHandler(console => console.navigateForward()));
66
- }
67
-
68
- registerKeybindings(keybindings: KeybindingRegistry): void {
69
- keybindings.registerKeybinding({
70
- command: ConsoleCommands.SELECT_ALL.id,
71
- keybinding: 'ctrlcmd+a',
72
- when: 'consoleContentFocus'
73
- });
74
- keybindings.registerKeybinding({
75
- command: ConsoleCommands.EXECUTE.id,
76
- keybinding: 'enter',
77
- when: 'consoleInputFocus'
78
- });
79
- keybindings.registerKeybinding({
80
- command: ConsoleCommands.NAVIGATE_BACK.id,
81
- keybinding: 'up',
82
- when: 'consoleInputFocus && consoleNavigationBackEnabled'
83
- });
84
- keybindings.registerKeybinding({
85
- command: ConsoleCommands.NAVIGATE_FORWARD.id,
86
- keybinding: 'down',
87
- when: 'consoleInputFocus && consoleNavigationForwardEnabled'
88
- });
89
- }
90
-
91
- registerMenus(menus: MenuModelRegistry): void {
92
- menus.registerMenuAction(ConsoleContextMenu.CLIPBOARD, {
93
- commandId: CommonCommands.COPY.id,
94
- label: CommonCommands.COPY.label,
95
- order: 'a1',
96
- });
97
- menus.registerMenuAction(ConsoleContextMenu.CLIPBOARD, {
98
- commandId: ConsoleCommands.SELECT_ALL.id,
99
- label: CommonCommands.SELECT_ALL.label,
100
- order: 'a2'
101
- });
102
- menus.registerMenuAction(ConsoleContextMenu.CLIPBOARD, {
103
- commandId: ConsoleCommands.COLLAPSE_ALL.id,
104
- label: nls.localizeByDefault('Collapse All'),
105
- order: 'a3'
106
- });
107
- menus.registerMenuAction(ConsoleContextMenu.CLEAR, {
108
- commandId: ConsoleCommands.CLEAR.id,
109
- label: nls.localizeByDefault('Clear Console')
110
- });
111
- }
112
-
113
- protected newCommandHandler(execute: ConsoleExecuteFunction): ConsoleCommandHandler {
114
- return new ConsoleCommandHandler(this.manager, execute);
115
- }
116
-
117
- }
118
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
119
- export type ConsoleExecuteFunction = (console: ConsoleWidget, ...args: any[]) => any;
120
- export class ConsoleCommandHandler implements CommandHandler {
121
-
122
- constructor(
123
- protected readonly manager: ConsoleManager,
124
- protected readonly doExecute: ConsoleExecuteFunction
125
- ) { }
126
-
127
- isEnabled(): boolean {
128
- return !!this.manager.currentConsole;
129
- }
130
-
131
- isVisible(): boolean {
132
- return !!this.manager.currentConsole;
133
- }
134
-
135
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
136
- execute(...args: any[]): any {
137
- const { currentConsole } = this.manager;
138
- if (currentConsole) {
139
- return this.doExecute(currentConsole, ...args);
140
- }
141
- }
142
-
143
- }
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 } from '@theia/core/shared/inversify';
18
+ import { Command, CommandContribution, CommandRegistry, MenuContribution, MenuModelRegistry, CommandHandler } from '@theia/core';
19
+ import { FrontendApplicationContribution, KeybindingContribution, KeybindingRegistry, CommonCommands } from '@theia/core/lib/browser';
20
+ import { ConsoleManager } from './console-manager';
21
+ import { ConsoleWidget } from './console-widget';
22
+ import { ConsoleContentWidget } from './console-content-widget';
23
+ import { nls } from '@theia/core/lib/common/nls';
24
+
25
+ export namespace ConsoleCommands {
26
+ export const SELECT_ALL: Command = {
27
+ id: 'console.selectAll'
28
+ };
29
+ export const COLLAPSE_ALL: Command = {
30
+ id: 'console.collapseAll'
31
+ };
32
+ export const CLEAR: Command = {
33
+ id: 'console.clear'
34
+ };
35
+ export const EXECUTE: Command = {
36
+ id: 'console.execute'
37
+ };
38
+ export const NAVIGATE_BACK: Command = {
39
+ id: 'console.navigatePrevious'
40
+ };
41
+ export const NAVIGATE_FORWARD: Command = {
42
+ id: 'console.navigateNext'
43
+ };
44
+ }
45
+
46
+ export namespace ConsoleContextMenu {
47
+ export const CLIPBOARD = [...ConsoleContentWidget.CONTEXT_MENU, '1_clipboard'];
48
+ export const CLEAR = [...ConsoleContentWidget.CONTEXT_MENU, '2_clear'];
49
+ }
50
+
51
+ @injectable()
52
+ export class ConsoleContribution implements FrontendApplicationContribution, CommandContribution, KeybindingContribution, MenuContribution {
53
+
54
+ @inject(ConsoleManager)
55
+ protected readonly manager: ConsoleManager;
56
+
57
+ initialize(): void { }
58
+
59
+ registerCommands(commands: CommandRegistry): void {
60
+ commands.registerCommand(ConsoleCommands.SELECT_ALL, this.newCommandHandler(console => console.selectAll()));
61
+ commands.registerCommand(ConsoleCommands.COLLAPSE_ALL, this.newCommandHandler(console => console.collapseAll()));
62
+ commands.registerCommand(ConsoleCommands.CLEAR, this.newCommandHandler(console => console.clear()));
63
+ commands.registerCommand(ConsoleCommands.EXECUTE, this.newCommandHandler(console => console.execute()));
64
+ commands.registerCommand(ConsoleCommands.NAVIGATE_BACK, this.newCommandHandler(console => console.navigateBack()));
65
+ commands.registerCommand(ConsoleCommands.NAVIGATE_FORWARD, this.newCommandHandler(console => console.navigateForward()));
66
+ }
67
+
68
+ registerKeybindings(keybindings: KeybindingRegistry): void {
69
+ keybindings.registerKeybinding({
70
+ command: ConsoleCommands.SELECT_ALL.id,
71
+ keybinding: 'ctrlcmd+a',
72
+ when: 'consoleContentFocus'
73
+ });
74
+ keybindings.registerKeybinding({
75
+ command: ConsoleCommands.EXECUTE.id,
76
+ keybinding: 'enter',
77
+ when: 'consoleInputFocus'
78
+ });
79
+ keybindings.registerKeybinding({
80
+ command: ConsoleCommands.NAVIGATE_BACK.id,
81
+ keybinding: 'up',
82
+ when: 'consoleInputFocus && consoleNavigationBackEnabled'
83
+ });
84
+ keybindings.registerKeybinding({
85
+ command: ConsoleCommands.NAVIGATE_FORWARD.id,
86
+ keybinding: 'down',
87
+ when: 'consoleInputFocus && consoleNavigationForwardEnabled'
88
+ });
89
+ }
90
+
91
+ registerMenus(menus: MenuModelRegistry): void {
92
+ menus.registerMenuAction(ConsoleContextMenu.CLIPBOARD, {
93
+ commandId: CommonCommands.COPY.id,
94
+ label: CommonCommands.COPY.label,
95
+ order: 'a1',
96
+ });
97
+ menus.registerMenuAction(ConsoleContextMenu.CLIPBOARD, {
98
+ commandId: ConsoleCommands.SELECT_ALL.id,
99
+ label: CommonCommands.SELECT_ALL.label,
100
+ order: 'a2'
101
+ });
102
+ menus.registerMenuAction(ConsoleContextMenu.CLIPBOARD, {
103
+ commandId: ConsoleCommands.COLLAPSE_ALL.id,
104
+ label: nls.localizeByDefault('Collapse All'),
105
+ order: 'a3'
106
+ });
107
+ menus.registerMenuAction(ConsoleContextMenu.CLEAR, {
108
+ commandId: ConsoleCommands.CLEAR.id,
109
+ label: nls.localizeByDefault('Clear Console')
110
+ });
111
+ }
112
+
113
+ protected newCommandHandler(execute: ConsoleExecuteFunction): ConsoleCommandHandler {
114
+ return new ConsoleCommandHandler(this.manager, execute);
115
+ }
116
+
117
+ }
118
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
119
+ export type ConsoleExecuteFunction = (console: ConsoleWidget, ...args: any[]) => any;
120
+ export class ConsoleCommandHandler implements CommandHandler {
121
+
122
+ constructor(
123
+ protected readonly manager: ConsoleManager,
124
+ protected readonly doExecute: ConsoleExecuteFunction
125
+ ) { }
126
+
127
+ isEnabled(): boolean {
128
+ return !!this.manager.currentConsole;
129
+ }
130
+
131
+ isVisible(): boolean {
132
+ return !!this.manager.currentConsole;
133
+ }
134
+
135
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
136
+ execute(...args: any[]): any {
137
+ const { currentConsole } = this.manager;
138
+ if (currentConsole) {
139
+ return this.doExecute(currentConsole, ...args);
140
+ }
141
+ }
142
+
143
+ }