@theia/terminal 1.40.1 → 1.42.0

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 (33) hide show
  1. package/lib/browser/base/terminal-widget.d.ts +3 -0
  2. package/lib/browser/base/terminal-widget.d.ts.map +1 -1
  3. package/lib/browser/base/terminal-widget.js.map +1 -1
  4. package/lib/browser/terminal-frontend-contribution.d.ts +1 -0
  5. package/lib/browser/terminal-frontend-contribution.d.ts.map +1 -1
  6. package/lib/browser/terminal-frontend-contribution.js +16 -6
  7. package/lib/browser/terminal-frontend-contribution.js.map +1 -1
  8. package/lib/browser/terminal-frontend-module.d.ts.map +1 -1
  9. package/lib/browser/terminal-frontend-module.js +0 -3
  10. package/lib/browser/terminal-frontend-module.js.map +1 -1
  11. package/lib/browser/terminal-widget-impl.d.ts +10 -1
  12. package/lib/browser/terminal-widget-impl.d.ts.map +1 -1
  13. package/lib/browser/terminal-widget-impl.js +69 -4
  14. package/lib/browser/terminal-widget-impl.js.map +1 -1
  15. package/lib/common/base-terminal-protocol.d.ts +8 -2
  16. package/lib/common/base-terminal-protocol.d.ts.map +1 -1
  17. package/lib/common/base-terminal-protocol.js.map +1 -1
  18. package/lib/node/base-terminal-server.d.ts +6 -2
  19. package/lib/node/base-terminal-server.d.ts.map +1 -1
  20. package/lib/node/base-terminal-server.js +35 -10
  21. package/lib/node/base-terminal-server.js.map +1 -1
  22. package/package.json +9 -9
  23. package/src/browser/base/terminal-widget.ts +4 -0
  24. package/src/browser/terminal-frontend-contribution.ts +17 -6
  25. package/src/browser/terminal-frontend-module.ts +1 -4
  26. package/src/browser/terminal-widget-impl.ts +78 -6
  27. package/src/common/base-terminal-protocol.ts +10 -3
  28. package/src/node/base-terminal-server.ts +37 -10
  29. package/lib/browser/terminal-keybinding-contexts.d.ts +0 -16
  30. package/lib/browser/terminal-keybinding-contexts.d.ts.map +0 -1
  31. package/lib/browser/terminal-keybinding-contexts.js +0 -72
  32. package/lib/browser/terminal-keybinding-contexts.js.map +0 -1
  33. package/src/browser/terminal-keybinding-contexts.ts +0 -52
@@ -43,6 +43,9 @@ import { Key } from '@theia/core/lib/browser/keys';
43
43
  import { nls } from '@theia/core/lib/common/nls';
44
44
  import { TerminalMenus } from './terminal-frontend-contribution';
45
45
  import debounce = require('p-debounce');
46
+ import { MarkdownString, MarkdownStringImpl } from '@theia/core/lib/common/markdown-rendering/markdown-string';
47
+ import { EnhancedPreviewWidget } from '@theia/core/lib/browser/widgets/enhanced-preview-widget';
48
+ import { MarkdownRenderer, MarkdownRendererFactory } from '@theia/core/lib/browser/markdown-rendering/markdown-renderer';
46
49
 
47
50
  export const TERMINAL_WIDGET_FACTORY_ID = 'terminal';
48
51
 
@@ -57,7 +60,7 @@ export interface TerminalContribution {
57
60
  }
58
61
 
59
62
  @injectable()
60
- export class TerminalWidgetImpl extends TerminalWidget implements StatefulWidget, ExtractableWidget {
63
+ export class TerminalWidgetImpl extends TerminalWidget implements StatefulWidget, ExtractableWidget, EnhancedPreviewWidget {
61
64
  readonly isExtractable: boolean = true;
62
65
  secondaryWindow: Window | undefined;
63
66
  location: TerminalLocationOptions;
@@ -81,6 +84,7 @@ export class TerminalWidgetImpl extends TerminalWidget implements StatefulWidget
81
84
  protected lastMousePosition: { x: number, y: number } | undefined;
82
85
  protected isAttachedCloseListener: boolean = false;
83
86
  protected shown = false;
87
+ protected enhancedPreviewNode: Node | undefined;
84
88
  override lastCwd = new URI();
85
89
 
86
90
  @inject(WorkspaceService) protected readonly workspaceService: WorkspaceService;
@@ -98,6 +102,13 @@ export class TerminalWidgetImpl extends TerminalWidget implements StatefulWidget
98
102
  @inject(TerminalThemeService) protected readonly themeService: TerminalThemeService;
99
103
  @inject(ShellCommandBuilder) protected readonly shellCommandBuilder: ShellCommandBuilder;
100
104
  @inject(ContextMenuRenderer) protected readonly contextMenuRenderer: ContextMenuRenderer;
105
+ @inject(MarkdownRendererFactory) protected readonly markdownRendererFactory: MarkdownRendererFactory;
106
+
107
+ protected _markdownRenderer: MarkdownRenderer | undefined;
108
+ protected get markdownRenderer(): MarkdownRenderer {
109
+ this._markdownRenderer ||= this.markdownRendererFactory();
110
+ return this._markdownRenderer;
111
+ }
101
112
 
102
113
  protected readonly onDidOpenEmitter = new Emitter<void>();
103
114
  readonly onDidOpen: Event<void> = this.onDidOpenEmitter.event;
@@ -206,21 +217,25 @@ export class TerminalWidgetImpl extends TerminalWidget implements StatefulWidget
206
217
  });
207
218
  this.toDispose.push(titleChangeListenerDispose);
208
219
 
209
- this.toDispose.push(this.terminalWatcher.onTerminalError(({ terminalId, error }) => {
220
+ this.toDispose.push(this.terminalWatcher.onTerminalError(({ terminalId, error, attached }) => {
210
221
  if (terminalId === this.terminalId) {
211
222
  this.exitStatus = { code: undefined, reason: TerminalExitReason.Process };
212
- this.dispose();
213
223
  this.logger.error(`The terminal process terminated. Cause: ${error}`);
224
+ if (!attached) {
225
+ this.dispose();
226
+ }
214
227
  }
215
228
  }));
216
- this.toDispose.push(this.terminalWatcher.onTerminalExit(({ terminalId, code, reason }) => {
229
+ this.toDispose.push(this.terminalWatcher.onTerminalExit(({ terminalId, code, reason, attached }) => {
217
230
  if (terminalId === this.terminalId) {
218
231
  if (reason) {
219
232
  this.exitStatus = { code, reason };
220
233
  } else {
221
234
  this.exitStatus = { code, reason: TerminalExitReason.Process };
222
235
  }
223
- this.dispose();
236
+ if (!attached) {
237
+ this.dispose();
238
+ }
224
239
  }
225
240
  }));
226
241
  this.toDispose.push(this.toDisposeOnConnect);
@@ -422,6 +437,13 @@ export class TerminalWidgetImpl extends TerminalWidget implements StatefulWidget
422
437
  return this.shellTerminalServer.getProcessInfo(this.terminalId);
423
438
  }
424
439
 
440
+ get envVarCollectionDescriptionsByExtension(): Promise<Map<string, string | MarkdownString | undefined>> {
441
+ if (!IBaseTerminalServer.validateId(this.terminalId)) {
442
+ return Promise.reject(new Error('terminal is not started'));
443
+ }
444
+ return this.shellTerminalServer.getEnvVarCollectionDescriptionsByExtension(this.terminalId);
445
+ }
446
+
425
447
  get terminalId(): number {
426
448
  return this._terminalId;
427
449
  }
@@ -502,6 +524,8 @@ export class TerminalWidgetImpl extends TerminalWidget implements StatefulWidget
502
524
  protected async attachTerminal(id: number): Promise<number> {
503
525
  const terminalId = await this.shellTerminalServer.attach(id);
504
526
  if (IBaseTerminalServer.validateId(terminalId)) {
527
+ // reset exit status if a new terminal process is attached
528
+ this.exitStatus = undefined;
505
529
  return terminalId;
506
530
  }
507
531
  this.logger.warn(`Failed attaching to terminal id ${id}, the terminal is most likely gone. Starting up a new terminal instead.`);
@@ -756,6 +780,10 @@ export class TerminalWidgetImpl extends TerminalWidget implements StatefulWidget
756
780
  if (this.exitStatus) {
757
781
  this.onTermDidClose.fire(this);
758
782
  }
783
+ if (this.enhancedPreviewNode) {
784
+ // don't use preview node anymore. rendered markdown will be disposed on super call
785
+ this.enhancedPreviewNode = undefined;
786
+ }
759
787
  super.dispose();
760
788
  }
761
789
 
@@ -776,7 +804,9 @@ export class TerminalWidgetImpl extends TerminalWidget implements StatefulWidget
776
804
  return;
777
805
  }
778
806
  if (!IBaseTerminalServer.validateId(this.terminalId)
779
- || !this.terminalService.getById(this.id)) {
807
+ || this.exitStatus
808
+ || !this.terminalService.getById(this.id)
809
+ ) {
780
810
  return;
781
811
  }
782
812
  const { cols, rows } = this.term;
@@ -859,4 +889,46 @@ export class TerminalWidgetImpl extends TerminalWidget implements StatefulWidget
859
889
  private disableEnterWhenAttachCloseListener(): boolean {
860
890
  return this.isAttachedCloseListener;
861
891
  }
892
+
893
+ getEnhancedPreviewNode(): Node | undefined {
894
+ if (this.enhancedPreviewNode) {
895
+ return this.enhancedPreviewNode;
896
+ }
897
+
898
+ this.enhancedPreviewNode = document.createElement('div');
899
+
900
+ Promise.all([this.envVarCollectionDescriptionsByExtension, this.processId, this.processInfo])
901
+ .then((values: [Map<string, string | MarkdownString | undefined>, number, TerminalProcessInfo]) => {
902
+ const extensions = values[0];
903
+ const processId = values[1];
904
+ const processInfo = values[2];
905
+
906
+ const markdown = new MarkdownStringImpl();
907
+ markdown.appendMarkdown('Process ID: ' + processId + '\\\n');
908
+ markdown.appendMarkdown('Command line: ' +
909
+ processInfo.executable +
910
+ ' ' +
911
+ processInfo.arguments.join(' ') +
912
+ '\n\n---\n\n');
913
+ markdown.appendMarkdown('The following extensions have contributed to this terminal\'s environment:\n');
914
+ extensions.forEach((value, key) => {
915
+ if (value === undefined) {
916
+ markdown.appendMarkdown('* ' + key + '\n');
917
+ } else if (typeof value === 'string') {
918
+ markdown.appendMarkdown('* ' + key + ': ' + value + '\n');
919
+ } else {
920
+ markdown.appendMarkdown('* ' + key + ': ' + value.value + '\n');
921
+ }
922
+ });
923
+
924
+ const enhancedPreviewNode = this.enhancedPreviewNode;
925
+ if (!this.isDisposed && enhancedPreviewNode) {
926
+ const result = this.markdownRenderer.render(markdown);
927
+ this.toDispose.push(result);
928
+ enhancedPreviewNode.appendChild(result.element);
929
+ }
930
+ });
931
+
932
+ return this.enhancedPreviewNode;
933
+ }
862
934
  }
@@ -16,6 +16,7 @@
16
16
 
17
17
  import { RpcServer } from '@theia/core/lib/common/messaging/proxy-factory';
18
18
  import { Disposable } from '@theia/core';
19
+ import { MarkdownString } from '@theia/core/lib/common/markdown-rendering/markdown-string';
19
20
 
20
21
  export interface TerminalProcessInfo {
21
22
  executable: string
@@ -28,6 +29,7 @@ export interface IBaseTerminalServer extends RpcServer<IBaseTerminalClient> {
28
29
  create(IBaseTerminalServerOptions: object): Promise<number>;
29
30
  getProcessId(id: number): Promise<number>;
30
31
  getProcessInfo(id: number): Promise<TerminalProcessInfo>;
32
+ getEnvVarCollectionDescriptionsByExtension(id: number): Promise<Map<string, string | MarkdownString | undefined>>;
31
33
  getCwdURI(id: number): Promise<string>;
32
34
  resize(id: number, cols: number, rows: number): Promise<void>;
33
35
  attach(id: number): Promise<number>;
@@ -48,7 +50,7 @@ export interface IBaseTerminalServer extends RpcServer<IBaseTerminalClient> {
48
50
  /**
49
51
  * Sets an extension's environment variable collection.
50
52
  */
51
- setCollection(extensionIdentifier: string, persistent: boolean, collection: SerializableEnvironmentVariableCollection): void;
53
+ setCollection(extensionIdentifier: string, persistent: boolean, collection: SerializableEnvironmentVariableCollection, description: string | MarkdownString | undefined): void;
52
54
  /**
53
55
  * Deletes an extension's environment variable collection.
54
56
  */
@@ -67,6 +69,8 @@ export interface IBaseTerminalExitEvent {
67
69
  code?: number;
68
70
  reason?: TerminalExitReason;
69
71
  signal?: string;
72
+
73
+ attached?: boolean;
70
74
  }
71
75
 
72
76
  export enum TerminalExitReason {
@@ -79,7 +83,8 @@ export enum TerminalExitReason {
79
83
 
80
84
  export interface IBaseTerminalErrorEvent {
81
85
  terminalId: number;
82
- error: Error
86
+ error: Error;
87
+ attached?: boolean;
83
88
  }
84
89
 
85
90
  export interface IBaseTerminalClient {
@@ -154,6 +159,7 @@ export interface EnvironmentVariableCollection {
154
159
 
155
160
  export interface EnvironmentVariableCollectionWithPersistence extends EnvironmentVariableCollection {
156
161
  readonly persistent: boolean;
162
+ readonly description: string | MarkdownString | undefined;
157
163
  }
158
164
 
159
165
  export enum EnvironmentVariableMutatorType {
@@ -186,7 +192,8 @@ export interface MergedEnvironmentVariableCollection {
186
192
 
187
193
  export interface SerializableExtensionEnvironmentVariableCollection {
188
194
  extensionIdentifier: string,
189
- collection: SerializableEnvironmentVariableCollection
195
+ collection: SerializableEnvironmentVariableCollection | undefined,
196
+ description: string | MarkdownString | undefined
190
197
  }
191
198
 
192
199
  export type SerializableEnvironmentVariableCollection = [string, EnvironmentVariableMutator][];
@@ -33,6 +33,7 @@ import {
33
33
  } from '../common/base-terminal-protocol';
34
34
  import { TerminalProcess, ProcessManager, TaskTerminalProcess } from '@theia/process/lib/node';
35
35
  import { ShellProcess } from './shell-process';
36
+ import { MarkdownString } from '@theia/core/lib/common/markdown-rendering/markdown-string';
36
37
 
37
38
  @injectable()
38
39
  export abstract class BaseTerminalServer implements IBaseTerminalServer {
@@ -77,6 +78,8 @@ export abstract class BaseTerminalServer implements IBaseTerminalServer {
77
78
  // Didn't execute `unregisterProcess` on terminal `exit` event to enable attaching task output to terminal,
78
79
  // Fixes https://github.com/eclipse-theia/theia/issues/2961
79
80
  terminal.unregisterProcess();
81
+ } else {
82
+ this.postAttachAttempted(terminal);
80
83
  }
81
84
  }
82
85
  }
@@ -100,6 +103,18 @@ export abstract class BaseTerminalServer implements IBaseTerminalServer {
100
103
  };
101
104
  }
102
105
 
106
+ async getEnvVarCollectionDescriptionsByExtension(id: number): Promise<Map<string, string | MarkdownString | undefined>> {
107
+ const terminal = this.processManager.get(id);
108
+ if (!(terminal instanceof TerminalProcess)) {
109
+ throw new Error(`terminal "${id}" does not exist`);
110
+ }
111
+ const result = new Map<string, string | MarkdownString | undefined>();
112
+ this.collections.forEach((value, key) => {
113
+ result.set(key, value.description);
114
+ });
115
+ return result;
116
+ }
117
+
103
118
  async getCwdURI(id: number): Promise<string> {
104
119
  const terminal = this.processManager.get(id);
105
120
  if (!(terminal instanceof TerminalProcess)) {
@@ -142,7 +157,7 @@ export abstract class BaseTerminalServer implements IBaseTerminalServer {
142
157
  this.client.updateTerminalEnvVariables();
143
158
  }
144
159
 
145
- protected postCreate(term: TerminalProcess): void {
160
+ protected notifyClientOnExit(term: TerminalProcess): DisposableCollection {
146
161
  const toDispose = new DisposableCollection();
147
162
 
148
163
  toDispose.push(term.onError(error => {
@@ -150,8 +165,9 @@ export abstract class BaseTerminalServer implements IBaseTerminalServer {
150
165
 
151
166
  if (this.client !== undefined) {
152
167
  this.client.onTerminalError({
153
- 'terminalId': term.id,
154
- 'error': new Error(`Failed to execute terminal process (${error.code})`),
168
+ terminalId: term.id,
169
+ error: new Error(`Failed to execute terminal process (${error.code})`),
170
+ attached: term instanceof TaskTerminalProcess && term.attachmentAttempted
155
171
  });
156
172
  }
157
173
  }));
@@ -159,14 +175,24 @@ export abstract class BaseTerminalServer implements IBaseTerminalServer {
159
175
  toDispose.push(term.onExit(event => {
160
176
  if (this.client !== undefined) {
161
177
  this.client.onTerminalExitChanged({
162
- 'terminalId': term.id,
163
- 'code': event.code,
164
- 'reason': TerminalExitReason.Process,
165
- 'signal': event.signal
178
+ terminalId: term.id,
179
+ code: event.code,
180
+ reason: TerminalExitReason.Process,
181
+ signal: event.signal,
182
+ attached: term instanceof TaskTerminalProcess && term.attachmentAttempted
166
183
  });
167
184
  }
168
185
  }));
186
+ return toDispose;
187
+ }
188
+
189
+ protected postCreate(term: TerminalProcess): void {
190
+ const toDispose = this.notifyClientOnExit(term);
191
+ this.terminalToDispose.set(term.id, toDispose);
192
+ }
169
193
 
194
+ protected postAttachAttempted(term: TaskTerminalProcess): void {
195
+ const toDispose = this.notifyClientOnExit(term);
170
196
  this.terminalToDispose.set(term.id, toDispose);
171
197
  }
172
198
 
@@ -176,8 +202,8 @@ export abstract class BaseTerminalServer implements IBaseTerminalServer {
176
202
  *--------------------------------------------------------------------------------------------*/
177
203
  // some code copied and modified from https://github.com/microsoft/vscode/blob/1.49.0/src/vs/workbench/contrib/terminal/common/environmentVariableService.ts
178
204
 
179
- setCollection(extensionIdentifier: string, persistent: boolean, collection: SerializableEnvironmentVariableCollection): void {
180
- const translatedCollection = { persistent, map: new Map<string, EnvironmentVariableMutator>(collection) };
205
+ setCollection(extensionIdentifier: string, persistent: boolean, collection: SerializableEnvironmentVariableCollection, description: string | MarkdownString | undefined): void {
206
+ const translatedCollection = { persistent, description, map: new Map<string, EnvironmentVariableMutator>(collection) };
181
207
  this.collections.set(extensionIdentifier, translatedCollection);
182
208
  this.updateCollections();
183
209
  }
@@ -198,7 +224,8 @@ export abstract class BaseTerminalServer implements IBaseTerminalServer {
198
224
  if (collection.persistent) {
199
225
  collectionsJson.push({
200
226
  extensionIdentifier,
201
- collection: [...this.collections.get(extensionIdentifier)!.map.entries()]
227
+ collection: [...this.collections.get(extensionIdentifier)!.map.entries()],
228
+ description: collection.description
202
229
  });
203
230
  }
204
231
  });
@@ -1,16 +0,0 @@
1
- import { KeybindingContext, ApplicationShell } from '@theia/core/lib/browser';
2
- export declare namespace TerminalKeybindingContexts {
3
- const terminalActive = "terminalActive";
4
- const terminalHideSearch = "hideSearch";
5
- }
6
- export declare class TerminalActiveContext implements KeybindingContext {
7
- readonly id: string;
8
- protected readonly shell: ApplicationShell;
9
- isEnabled(): boolean;
10
- }
11
- export declare class TerminalSearchVisibleContext implements KeybindingContext {
12
- readonly id: string;
13
- protected readonly shell: ApplicationShell;
14
- isEnabled(): boolean;
15
- }
16
- //# sourceMappingURL=terminal-keybinding-contexts.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"terminal-keybinding-contexts.d.ts","sourceRoot":"","sources":["../../src/browser/terminal-keybinding-contexts.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAG9E,yBAAiB,0BAA0B,CAAC;IACjC,MAAM,cAAc,mBAAmB,CAAC;IACxC,MAAM,kBAAkB,eAAe,CAAC;CAClD;AAED,qBACa,qBAAsB,YAAW,iBAAiB;IAC3D,QAAQ,CAAC,EAAE,EAAE,MAAM,CAA6C;IAGhE,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,gBAAgB,CAAC;IAE3C,SAAS,IAAI,OAAO;CAGvB;AAED,qBACa,4BAA6B,YAAW,iBAAiB;IAClE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAiD;IAGpE,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,gBAAgB,CAAC;IAE3C,SAAS,IAAI,OAAO;CAOvB"}
@@ -1,72 +0,0 @@
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.TerminalSearchVisibleContext = exports.TerminalActiveContext = exports.TerminalKeybindingContexts = void 0;
28
- const inversify_1 = require("@theia/core/shared/inversify");
29
- const browser_1 = require("@theia/core/lib/browser");
30
- const terminal_widget_1 = require("./base/terminal-widget");
31
- var TerminalKeybindingContexts;
32
- (function (TerminalKeybindingContexts) {
33
- TerminalKeybindingContexts.terminalActive = 'terminalActive';
34
- TerminalKeybindingContexts.terminalHideSearch = 'hideSearch';
35
- })(TerminalKeybindingContexts = exports.TerminalKeybindingContexts || (exports.TerminalKeybindingContexts = {}));
36
- let TerminalActiveContext = class TerminalActiveContext {
37
- constructor() {
38
- this.id = TerminalKeybindingContexts.terminalActive;
39
- }
40
- isEnabled() {
41
- return this.shell.activeWidget instanceof terminal_widget_1.TerminalWidget;
42
- }
43
- };
44
- __decorate([
45
- (0, inversify_1.inject)(browser_1.ApplicationShell),
46
- __metadata("design:type", browser_1.ApplicationShell)
47
- ], TerminalActiveContext.prototype, "shell", void 0);
48
- TerminalActiveContext = __decorate([
49
- (0, inversify_1.injectable)()
50
- ], TerminalActiveContext);
51
- exports.TerminalActiveContext = TerminalActiveContext;
52
- let TerminalSearchVisibleContext = class TerminalSearchVisibleContext {
53
- constructor() {
54
- this.id = TerminalKeybindingContexts.terminalHideSearch;
55
- }
56
- isEnabled() {
57
- if (!(this.shell.activeWidget instanceof terminal_widget_1.TerminalWidget)) {
58
- return false;
59
- }
60
- const searchWidget = this.shell.activeWidget.getSearchBox();
61
- return searchWidget.isVisible;
62
- }
63
- };
64
- __decorate([
65
- (0, inversify_1.inject)(browser_1.ApplicationShell),
66
- __metadata("design:type", browser_1.ApplicationShell)
67
- ], TerminalSearchVisibleContext.prototype, "shell", void 0);
68
- TerminalSearchVisibleContext = __decorate([
69
- (0, inversify_1.injectable)()
70
- ], TerminalSearchVisibleContext);
71
- exports.TerminalSearchVisibleContext = TerminalSearchVisibleContext;
72
- //# sourceMappingURL=terminal-keybinding-contexts.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"terminal-keybinding-contexts.js","sourceRoot":"","sources":["../../src/browser/terminal-keybinding-contexts.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;;;;;;;;;;AAEhF,4DAAkE;AAClE,qDAA8E;AAC9E,4DAAwD;AAExD,IAAiB,0BAA0B,CAG1C;AAHD,WAAiB,0BAA0B;IAC1B,yCAAc,GAAG,gBAAgB,CAAC;IAClC,6CAAkB,GAAG,YAAY,CAAC;AACnD,CAAC,EAHgB,0BAA0B,GAA1B,kCAA0B,KAA1B,kCAA0B,QAG1C;AAGD,IAAa,qBAAqB,GAAlC,MAAa,qBAAqB;IAAlC;QACa,OAAE,GAAW,0BAA0B,CAAC,cAAc,CAAC;IAQpE,CAAC;IAHG,SAAS;QACL,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,YAAY,gCAAc,CAAC;IAC7D,CAAC;CACJ,CAAA;AALG;IADC,IAAA,kBAAM,EAAC,0BAAgB,CAAC;8BACC,0BAAgB;oDAAC;AAJlC,qBAAqB;IADjC,IAAA,sBAAU,GAAE;GACA,qBAAqB,CASjC;AATY,sDAAqB;AAYlC,IAAa,4BAA4B,GAAzC,MAAa,4BAA4B;IAAzC;QACa,OAAE,GAAW,0BAA0B,CAAC,kBAAkB,CAAC;IAYxE,CAAC;IAPG,SAAS;QACL,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,YAAY,gCAAc,CAAC,EAAE;YACtD,OAAO,KAAK,CAAC;SAChB;QACD,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,YAAY,EAAE,CAAC;QAC5D,OAAO,YAAY,CAAC,SAAS,CAAC;IAClC,CAAC;CACJ,CAAA;AATG;IADC,IAAA,kBAAM,EAAC,0BAAgB,CAAC;8BACC,0BAAgB;2DAAC;AAJlC,4BAA4B;IADxC,IAAA,sBAAU,GAAE;GACA,4BAA4B,CAaxC;AAbY,oEAA4B"}
@@ -1,52 +0,0 @@
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 { KeybindingContext, ApplicationShell } from '@theia/core/lib/browser';
19
- import { TerminalWidget } from './base/terminal-widget';
20
-
21
- export namespace TerminalKeybindingContexts {
22
- export const terminalActive = 'terminalActive';
23
- export const terminalHideSearch = 'hideSearch';
24
- }
25
-
26
- @injectable()
27
- export class TerminalActiveContext implements KeybindingContext {
28
- readonly id: string = TerminalKeybindingContexts.terminalActive;
29
-
30
- @inject(ApplicationShell)
31
- protected readonly shell: ApplicationShell;
32
-
33
- isEnabled(): boolean {
34
- return this.shell.activeWidget instanceof TerminalWidget;
35
- }
36
- }
37
-
38
- @injectable()
39
- export class TerminalSearchVisibleContext implements KeybindingContext {
40
- readonly id: string = TerminalKeybindingContexts.terminalHideSearch;
41
-
42
- @inject(ApplicationShell)
43
- protected readonly shell: ApplicationShell;
44
-
45
- isEnabled(): boolean {
46
- if (!(this.shell.activeWidget instanceof TerminalWidget)) {
47
- return false;
48
- }
49
- const searchWidget = this.shell.activeWidget.getSearchBox();
50
- return searchWidget.isVisible;
51
- }
52
- }