@theia/console 1.34.2 → 1.34.3

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 (36) hide show
  1. package/LICENSE +641 -641
  2. package/README.md +30 -30
  3. package/lib/browser/ansi-console-item.d.ts +12 -12
  4. package/lib/browser/ansi-console-item.js +38 -38
  5. package/lib/browser/console-content-widget.d.ts +17 -17
  6. package/lib/browser/console-content-widget.js +90 -90
  7. package/lib/browser/console-contribution.d.ts +33 -33
  8. package/lib/browser/console-contribution.js +144 -144
  9. package/lib/browser/console-frontend-module.d.ts +4 -4
  10. package/lib/browser/console-frontend-module.js +36 -36
  11. package/lib/browser/console-history.d.ts +19 -19
  12. package/lib/browser/console-history.js +74 -74
  13. package/lib/browser/console-keybinding-contexts.d.ts +39 -39
  14. package/lib/browser/console-keybinding-contexts.js +118 -118
  15. package/lib/browser/console-manager.d.ts +7 -7
  16. package/lib/browser/console-manager.js +48 -48
  17. package/lib/browser/console-session-manager.d.ts +31 -31
  18. package/lib/browser/console-session-manager.js +116 -116
  19. package/lib/browser/console-session.d.ts +27 -27
  20. package/lib/browser/console-session.js +56 -56
  21. package/lib/browser/console-widget.d.ts +62 -62
  22. package/lib/browser/console-widget.js +247 -247
  23. package/lib/package.spec.js +25 -25
  24. package/package.json +5 -5
  25. package/src/browser/ansi-console-item.tsx +48 -48
  26. package/src/browser/console-content-widget.tsx +91 -91
  27. package/src/browser/console-contribution.ts +144 -144
  28. package/src/browser/console-frontend-module.ts +37 -37
  29. package/src/browser/console-history.ts +76 -76
  30. package/src/browser/console-keybinding-contexts.ts +107 -107
  31. package/src/browser/console-manager.ts +37 -37
  32. package/src/browser/console-session-manager.ts +121 -121
  33. package/src/browser/console-session.ts +61 -61
  34. package/src/browser/console-widget.ts +273 -273
  35. package/src/browser/style/index.css +49 -49
  36. package/src/package.spec.ts +28 -28
@@ -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 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 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 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 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,144 +1,144 @@
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 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 { ConsoleKeybindingContexts } from './console-keybinding-contexts';
22
- import { ConsoleWidget } from './console-widget';
23
- import { ConsoleContentWidget } from './console-content-widget';
24
- import { nls } from '@theia/core/lib/common/nls';
25
-
26
- export namespace ConsoleCommands {
27
- export const SELECT_ALL: Command = {
28
- id: 'console.selectAll'
29
- };
30
- export const COLLAPSE_ALL: Command = {
31
- id: 'console.collapseAll'
32
- };
33
- export const CLEAR: Command = {
34
- id: 'console.clear'
35
- };
36
- export const EXECUTE: Command = {
37
- id: 'console.execute'
38
- };
39
- export const NAVIGATE_BACK: Command = {
40
- id: 'console.navigatePrevious'
41
- };
42
- export const NAVIGATE_FORWARD: Command = {
43
- id: 'console.navigateNext'
44
- };
45
- }
46
-
47
- export namespace ConsoleContextMenu {
48
- export const CLIPBOARD = [...ConsoleContentWidget.CONTEXT_MENU, '1_clipboard'];
49
- export const CLEAR = [...ConsoleContentWidget.CONTEXT_MENU, '2_clear'];
50
- }
51
-
52
- @injectable()
53
- export class ConsoleContribution implements FrontendApplicationContribution, CommandContribution, KeybindingContribution, MenuContribution {
54
-
55
- @inject(ConsoleManager)
56
- protected readonly manager: ConsoleManager;
57
-
58
- initialize(): void { }
59
-
60
- registerCommands(commands: CommandRegistry): void {
61
- commands.registerCommand(ConsoleCommands.SELECT_ALL, this.newCommandHandler(console => console.selectAll()));
62
- commands.registerCommand(ConsoleCommands.COLLAPSE_ALL, this.newCommandHandler(console => console.collapseAll()));
63
- commands.registerCommand(ConsoleCommands.CLEAR, this.newCommandHandler(console => console.clear()));
64
- commands.registerCommand(ConsoleCommands.EXECUTE, this.newCommandHandler(console => console.execute()));
65
- commands.registerCommand(ConsoleCommands.NAVIGATE_BACK, this.newCommandHandler(console => console.navigateBack()));
66
- commands.registerCommand(ConsoleCommands.NAVIGATE_FORWARD, this.newCommandHandler(console => console.navigateForward()));
67
- }
68
-
69
- registerKeybindings(keybindings: KeybindingRegistry): void {
70
- keybindings.registerKeybinding({
71
- command: ConsoleCommands.SELECT_ALL.id,
72
- keybinding: 'ctrlcmd+a',
73
- context: ConsoleKeybindingContexts.consoleContentFocus
74
- });
75
- keybindings.registerKeybinding({
76
- command: ConsoleCommands.EXECUTE.id,
77
- keybinding: 'enter',
78
- context: ConsoleKeybindingContexts.consoleInputFocus
79
- });
80
- keybindings.registerKeybinding({
81
- command: ConsoleCommands.NAVIGATE_BACK.id,
82
- keybinding: 'up',
83
- context: ConsoleKeybindingContexts.consoleNavigationBackEnabled
84
- });
85
- keybindings.registerKeybinding({
86
- command: ConsoleCommands.NAVIGATE_FORWARD.id,
87
- keybinding: 'down',
88
- context: ConsoleKeybindingContexts.consoleNavigationForwardEnabled
89
- });
90
- }
91
-
92
- registerMenus(menus: MenuModelRegistry): void {
93
- menus.registerMenuAction(ConsoleContextMenu.CLIPBOARD, {
94
- commandId: CommonCommands.COPY.id,
95
- label: CommonCommands.COPY.label,
96
- order: 'a1',
97
- });
98
- menus.registerMenuAction(ConsoleContextMenu.CLIPBOARD, {
99
- commandId: ConsoleCommands.SELECT_ALL.id,
100
- label: CommonCommands.SELECT_ALL.label,
101
- order: 'a2'
102
- });
103
- menus.registerMenuAction(ConsoleContextMenu.CLIPBOARD, {
104
- commandId: ConsoleCommands.COLLAPSE_ALL.id,
105
- label: nls.localizeByDefault('Collapse All'),
106
- order: 'a3'
107
- });
108
- menus.registerMenuAction(ConsoleContextMenu.CLEAR, {
109
- commandId: ConsoleCommands.CLEAR.id,
110
- label: nls.localizeByDefault('Clear Console')
111
- });
112
- }
113
-
114
- protected newCommandHandler(execute: ConsoleExecuteFunction): ConsoleCommandHandler {
115
- return new ConsoleCommandHandler(this.manager, execute);
116
- }
117
-
118
- }
119
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
120
- export type ConsoleExecuteFunction = (console: ConsoleWidget, ...args: any[]) => any;
121
- export class ConsoleCommandHandler implements CommandHandler {
122
-
123
- constructor(
124
- protected readonly manager: ConsoleManager,
125
- protected readonly doExecute: ConsoleExecuteFunction
126
- ) { }
127
-
128
- isEnabled(): boolean {
129
- return !!this.manager.currentConsole;
130
- }
131
-
132
- isVisible(): boolean {
133
- return !!this.manager.currentConsole;
134
- }
135
-
136
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
137
- execute(...args: any[]): any {
138
- const { currentConsole } = this.manager;
139
- if (currentConsole) {
140
- return this.doExecute(currentConsole, ...args);
141
- }
142
- }
143
-
144
- }
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 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 { ConsoleKeybindingContexts } from './console-keybinding-contexts';
22
+ import { ConsoleWidget } from './console-widget';
23
+ import { ConsoleContentWidget } from './console-content-widget';
24
+ import { nls } from '@theia/core/lib/common/nls';
25
+
26
+ export namespace ConsoleCommands {
27
+ export const SELECT_ALL: Command = {
28
+ id: 'console.selectAll'
29
+ };
30
+ export const COLLAPSE_ALL: Command = {
31
+ id: 'console.collapseAll'
32
+ };
33
+ export const CLEAR: Command = {
34
+ id: 'console.clear'
35
+ };
36
+ export const EXECUTE: Command = {
37
+ id: 'console.execute'
38
+ };
39
+ export const NAVIGATE_BACK: Command = {
40
+ id: 'console.navigatePrevious'
41
+ };
42
+ export const NAVIGATE_FORWARD: Command = {
43
+ id: 'console.navigateNext'
44
+ };
45
+ }
46
+
47
+ export namespace ConsoleContextMenu {
48
+ export const CLIPBOARD = [...ConsoleContentWidget.CONTEXT_MENU, '1_clipboard'];
49
+ export const CLEAR = [...ConsoleContentWidget.CONTEXT_MENU, '2_clear'];
50
+ }
51
+
52
+ @injectable()
53
+ export class ConsoleContribution implements FrontendApplicationContribution, CommandContribution, KeybindingContribution, MenuContribution {
54
+
55
+ @inject(ConsoleManager)
56
+ protected readonly manager: ConsoleManager;
57
+
58
+ initialize(): void { }
59
+
60
+ registerCommands(commands: CommandRegistry): void {
61
+ commands.registerCommand(ConsoleCommands.SELECT_ALL, this.newCommandHandler(console => console.selectAll()));
62
+ commands.registerCommand(ConsoleCommands.COLLAPSE_ALL, this.newCommandHandler(console => console.collapseAll()));
63
+ commands.registerCommand(ConsoleCommands.CLEAR, this.newCommandHandler(console => console.clear()));
64
+ commands.registerCommand(ConsoleCommands.EXECUTE, this.newCommandHandler(console => console.execute()));
65
+ commands.registerCommand(ConsoleCommands.NAVIGATE_BACK, this.newCommandHandler(console => console.navigateBack()));
66
+ commands.registerCommand(ConsoleCommands.NAVIGATE_FORWARD, this.newCommandHandler(console => console.navigateForward()));
67
+ }
68
+
69
+ registerKeybindings(keybindings: KeybindingRegistry): void {
70
+ keybindings.registerKeybinding({
71
+ command: ConsoleCommands.SELECT_ALL.id,
72
+ keybinding: 'ctrlcmd+a',
73
+ context: ConsoleKeybindingContexts.consoleContentFocus
74
+ });
75
+ keybindings.registerKeybinding({
76
+ command: ConsoleCommands.EXECUTE.id,
77
+ keybinding: 'enter',
78
+ context: ConsoleKeybindingContexts.consoleInputFocus
79
+ });
80
+ keybindings.registerKeybinding({
81
+ command: ConsoleCommands.NAVIGATE_BACK.id,
82
+ keybinding: 'up',
83
+ context: ConsoleKeybindingContexts.consoleNavigationBackEnabled
84
+ });
85
+ keybindings.registerKeybinding({
86
+ command: ConsoleCommands.NAVIGATE_FORWARD.id,
87
+ keybinding: 'down',
88
+ context: ConsoleKeybindingContexts.consoleNavigationForwardEnabled
89
+ });
90
+ }
91
+
92
+ registerMenus(menus: MenuModelRegistry): void {
93
+ menus.registerMenuAction(ConsoleContextMenu.CLIPBOARD, {
94
+ commandId: CommonCommands.COPY.id,
95
+ label: CommonCommands.COPY.label,
96
+ order: 'a1',
97
+ });
98
+ menus.registerMenuAction(ConsoleContextMenu.CLIPBOARD, {
99
+ commandId: ConsoleCommands.SELECT_ALL.id,
100
+ label: CommonCommands.SELECT_ALL.label,
101
+ order: 'a2'
102
+ });
103
+ menus.registerMenuAction(ConsoleContextMenu.CLIPBOARD, {
104
+ commandId: ConsoleCommands.COLLAPSE_ALL.id,
105
+ label: nls.localizeByDefault('Collapse All'),
106
+ order: 'a3'
107
+ });
108
+ menus.registerMenuAction(ConsoleContextMenu.CLEAR, {
109
+ commandId: ConsoleCommands.CLEAR.id,
110
+ label: nls.localizeByDefault('Clear Console')
111
+ });
112
+ }
113
+
114
+ protected newCommandHandler(execute: ConsoleExecuteFunction): ConsoleCommandHandler {
115
+ return new ConsoleCommandHandler(this.manager, execute);
116
+ }
117
+
118
+ }
119
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
120
+ export type ConsoleExecuteFunction = (console: ConsoleWidget, ...args: any[]) => any;
121
+ export class ConsoleCommandHandler implements CommandHandler {
122
+
123
+ constructor(
124
+ protected readonly manager: ConsoleManager,
125
+ protected readonly doExecute: ConsoleExecuteFunction
126
+ ) { }
127
+
128
+ isEnabled(): boolean {
129
+ return !!this.manager.currentConsole;
130
+ }
131
+
132
+ isVisible(): boolean {
133
+ return !!this.manager.currentConsole;
134
+ }
135
+
136
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
137
+ execute(...args: any[]): any {
138
+ const { currentConsole } = this.manager;
139
+ if (currentConsole) {
140
+ return this.doExecute(currentConsole, ...args);
141
+ }
142
+ }
143
+
144
+ }
@@ -1,37 +1,37 @@
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 WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
-
17
- import { ContainerModule } from '@theia/core/shared/inversify';
18
- import { CommandContribution, MenuContribution } from '@theia/core';
19
- import { FrontendApplicationContribution, KeybindingContext, KeybindingContribution } from '@theia/core/lib/browser';
20
- import { ConsoleContribution } from './console-contribution';
21
- import { ConsoleManager } from './console-manager';
22
- import { ConsoleInputFocusContext, ConsoleNavigationBackEnabled, ConsoleNavigationForwardEnabled, ConsoleContentFocusContext } from './console-keybinding-contexts';
23
-
24
- import '../../src/browser/style/index.css';
25
-
26
- export default new ContainerModule(bind => {
27
- bind(ConsoleManager).toSelf().inSingletonScope();
28
- bind(KeybindingContext).to(ConsoleInputFocusContext).inSingletonScope();
29
- bind(KeybindingContext).to(ConsoleContentFocusContext).inSingletonScope();
30
- bind(KeybindingContext).to(ConsoleNavigationBackEnabled).inSingletonScope();
31
- bind(KeybindingContext).to(ConsoleNavigationForwardEnabled).inSingletonScope();
32
- bind(ConsoleContribution).toSelf().inSingletonScope();
33
- bind(FrontendApplicationContribution).toService(ConsoleContribution);
34
- bind(CommandContribution).toService(ConsoleContribution);
35
- bind(KeybindingContribution).toService(ConsoleContribution);
36
- bind(MenuContribution).toService(ConsoleContribution);
37
- });
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 WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { ContainerModule } from '@theia/core/shared/inversify';
18
+ import { CommandContribution, MenuContribution } from '@theia/core';
19
+ import { FrontendApplicationContribution, KeybindingContext, KeybindingContribution } from '@theia/core/lib/browser';
20
+ import { ConsoleContribution } from './console-contribution';
21
+ import { ConsoleManager } from './console-manager';
22
+ import { ConsoleInputFocusContext, ConsoleNavigationBackEnabled, ConsoleNavigationForwardEnabled, ConsoleContentFocusContext } from './console-keybinding-contexts';
23
+
24
+ import '../../src/browser/style/index.css';
25
+
26
+ export default new ContainerModule(bind => {
27
+ bind(ConsoleManager).toSelf().inSingletonScope();
28
+ bind(KeybindingContext).to(ConsoleInputFocusContext).inSingletonScope();
29
+ bind(KeybindingContext).to(ConsoleContentFocusContext).inSingletonScope();
30
+ bind(KeybindingContext).to(ConsoleNavigationBackEnabled).inSingletonScope();
31
+ bind(KeybindingContext).to(ConsoleNavigationForwardEnabled).inSingletonScope();
32
+ bind(ConsoleContribution).toSelf().inSingletonScope();
33
+ bind(FrontendApplicationContribution).toService(ConsoleContribution);
34
+ bind(CommandContribution).toService(ConsoleContribution);
35
+ bind(KeybindingContribution).toService(ConsoleContribution);
36
+ bind(MenuContribution).toService(ConsoleContribution);
37
+ });