@theia/terminal 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.
- package/README.md +30 -30
- package/lib/browser/base/terminal-service.d.ts +34 -34
- package/lib/browser/base/terminal-service.js +7 -7
- package/lib/browser/base/terminal-widget.d.ts +192 -192
- package/lib/browser/base/terminal-widget.js +34 -34
- package/lib/browser/index.d.ts +1 -1
- package/lib/browser/index.js +28 -28
- package/lib/browser/search/terminal-search-container.d.ts +3 -3
- package/lib/browser/search/terminal-search-container.js +28 -28
- package/lib/browser/search/terminal-search-widget.d.ts +30 -30
- package/lib/browser/search/terminal-search-widget.js +147 -147
- package/lib/browser/shell-terminal-profile.d.ts +20 -20
- package/lib/browser/shell-terminal-profile.js +42 -42
- package/lib/browser/terminal-contribution.d.ts +3 -3
- package/lib/browser/terminal-contribution.js +20 -20
- package/lib/browser/terminal-copy-on-selection-handler.d.ts +10 -10
- package/lib/browser/terminal-copy-on-selection-handler.js +103 -103
- package/lib/browser/terminal-file-link-provider.d.ts +24 -24
- package/lib/browser/terminal-file-link-provider.js +200 -200
- package/lib/browser/terminal-frontend-contribution.d.ts +115 -115
- package/lib/browser/terminal-frontend-contribution.d.ts.map +1 -1
- package/lib/browser/terminal-frontend-contribution.js +1078 -1056
- package/lib/browser/terminal-frontend-contribution.js.map +1 -1
- package/lib/browser/terminal-frontend-module.d.ts +5 -5
- package/lib/browser/terminal-frontend-module.js +117 -117
- package/lib/browser/terminal-link-helpers.d.ts +27 -27
- package/lib/browser/terminal-link-helpers.js +155 -155
- package/lib/browser/terminal-link-provider.d.ts +51 -51
- package/lib/browser/terminal-link-provider.js +197 -197
- package/lib/browser/terminal-preferences.d.ts +61 -61
- package/lib/browser/terminal-preferences.d.ts.map +1 -1
- package/lib/browser/terminal-preferences.js +357 -356
- package/lib/browser/terminal-preferences.js.map +1 -1
- package/lib/browser/terminal-profile-service.d.ts +58 -58
- package/lib/browser/terminal-profile-service.js +158 -158
- package/lib/browser/terminal-quick-open-service.d.ts +36 -36
- package/lib/browser/terminal-quick-open-service.js +137 -137
- package/lib/browser/terminal-theme-service.d.ts +21 -21
- package/lib/browser/terminal-theme-service.d.ts.map +1 -1
- package/lib/browser/terminal-theme-service.js +222 -218
- package/lib/browser/terminal-theme-service.js.map +1 -1
- package/lib/browser/terminal-url-link-provider.d.ts +11 -11
- package/lib/browser/terminal-url-link-provider.js +76 -76
- package/lib/browser/terminal-widget-impl.d.ts +180 -187
- package/lib/browser/terminal-widget-impl.d.ts.map +1 -1
- package/lib/browser/terminal-widget-impl.js +857 -867
- package/lib/browser/terminal-widget-impl.js.map +1 -1
- package/lib/common/base-terminal-protocol.d.ts +55 -55
- package/lib/common/base-terminal-protocol.js +84 -84
- package/lib/common/shell-terminal-protocol.d.ts +66 -66
- package/lib/common/shell-terminal-protocol.js +35 -35
- package/lib/common/terminal-common-module.d.ts +7 -7
- package/lib/common/terminal-common-module.js +31 -31
- package/lib/common/terminal-protocol.d.ts +12 -12
- package/lib/common/terminal-protocol.js +21 -21
- package/lib/common/terminal-watcher.d.ts +13 -13
- package/lib/common/terminal-watcher.js +70 -70
- package/lib/node/base-terminal-server.d.ts +24 -24
- package/lib/node/base-terminal-server.js +168 -168
- package/lib/node/buffering-stream.d.ts +39 -39
- package/lib/node/buffering-stream.js +75 -75
- package/lib/node/buffering-stream.spec.d.ts +1 -1
- package/lib/node/buffering-stream.spec.js +43 -43
- package/lib/node/index.d.ts +1 -1
- package/lib/node/index.js +28 -28
- package/lib/node/shell-process.d.ts +27 -27
- package/lib/node/shell-process.js +107 -107
- package/lib/node/shell-process.js.map +1 -1
- package/lib/node/shell-terminal-server.d.ts +30 -30
- package/lib/node/shell-terminal-server.js +212 -212
- package/lib/node/shell-terminal-server.spec.d.ts +1 -1
- package/lib/node/shell-terminal-server.spec.js +35 -35
- package/lib/node/terminal-backend-contribution.d.ts +9 -9
- package/lib/node/terminal-backend-contribution.js +75 -75
- package/lib/node/terminal-backend-contribution.slow-spec.d.ts +1 -1
- package/lib/node/terminal-backend-contribution.slow-spec.js +54 -54
- package/lib/node/terminal-backend-module.d.ts +11 -11
- package/lib/node/terminal-backend-module.js +69 -69
- package/lib/node/terminal-server.d.ts +9 -9
- package/lib/node/terminal-server.js +64 -64
- package/lib/node/terminal-server.spec.d.ts +1 -1
- package/lib/node/terminal-server.spec.js +41 -41
- package/lib/node/test/terminal-test-container.d.ts +2 -2
- package/lib/node/test/terminal-test-container.js +40 -40
- package/lib/package.spec.js +25 -25
- package/package.json +12 -12
- package/src/browser/base/terminal-service.ts +60 -60
- package/src/browser/base/terminal-widget.ts +254 -254
- package/src/browser/index.ts +17 -17
- package/src/browser/search/terminal-search-container.ts +28 -28
- package/src/browser/search/terminal-search-widget.tsx +161 -161
- package/src/browser/shell-terminal-profile.ts +45 -45
- package/src/browser/style/terminal-search.css +99 -99
- package/src/browser/style/terminal.css +32 -32
- package/src/browser/terminal-contribution.ts +19 -19
- package/src/browser/terminal-copy-on-selection-handler.ts +92 -92
- package/src/browser/terminal-file-link-provider.ts +200 -200
- package/src/browser/terminal-frontend-contribution.ts +1120 -1098
- package/src/browser/terminal-frontend-module.ts +136 -136
- package/src/browser/terminal-link-helpers.ts +187 -187
- package/src/browser/terminal-link-provider.ts +203 -203
- package/src/browser/terminal-preferences.ts +428 -427
- package/src/browser/terminal-profile-service.ts +180 -180
- package/src/browser/terminal-quick-open-service.ts +132 -132
- package/src/browser/terminal-theme-service.ts +213 -209
- package/src/browser/terminal-url-link-provider.ts +66 -66
- package/src/browser/terminal-widget-impl.ts +939 -936
- package/src/common/base-terminal-protocol.ts +125 -125
- package/src/common/shell-terminal-protocol.ts +103 -103
- package/src/common/terminal-common-module.ts +30 -30
- package/src/common/terminal-protocol.ts +32 -32
- package/src/common/terminal-watcher.ts +69 -69
- package/src/node/base-terminal-server.ts +173 -173
- package/src/node/buffering-stream.spec.ts +46 -46
- package/src/node/buffering-stream.ts +95 -95
- package/src/node/index.ts +17 -17
- package/src/node/shell-process.ts +101 -101
- package/src/node/shell-terminal-server.spec.ts +40 -40
- package/src/node/shell-terminal-server.ts +221 -221
- package/src/node/terminal-backend-contribution.slow-spec.ts +63 -63
- package/src/node/terminal-backend-contribution.ts +60 -60
- package/src/node/terminal-backend-module.ts +82 -82
- package/src/node/terminal-server.spec.ts +47 -47
- package/src/node/terminal-server.ts +52 -52
- package/src/node/test/terminal-test-container.ts +39 -39
- package/src/package.spec.ts +28 -28
|
@@ -1,95 +1,95 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2022 Ericsson 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 { Emitter, Event } from '@theia/core/lib/common/event';
|
|
18
|
-
|
|
19
|
-
export interface BufferingStreamOptions {
|
|
20
|
-
/**
|
|
21
|
-
* Max size in bytes of the chunks being emitted.
|
|
22
|
-
*/
|
|
23
|
-
maxChunkSize?: number
|
|
24
|
-
/**
|
|
25
|
-
* Amount of time in milliseconds to wait between the moment we start
|
|
26
|
-
* buffering data and when we emit the buffered chunk.
|
|
27
|
-
*/
|
|
28
|
-
emitInterval?: number
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* This component will buffer whatever is pushed to it and emit chunks back
|
|
33
|
-
* every {@link BufferingStreamOptions.emitInterval}. It will also ensure that
|
|
34
|
-
* the emitted chunks never exceed {@link BufferingStreamOptions.maxChunkSize}.
|
|
35
|
-
*/
|
|
36
|
-
export class BufferingStream<T> {
|
|
37
|
-
protected buffer?: T;
|
|
38
|
-
protected timeout?: NodeJS.Timeout;
|
|
39
|
-
protected maxChunkSize: number;
|
|
40
|
-
protected emitInterval: number;
|
|
41
|
-
|
|
42
|
-
protected onDataEmitter = new Emitter<T>();
|
|
43
|
-
protected readonly concat: (left: T, right: T) => T;
|
|
44
|
-
protected readonly slice: (what: T, start?: number, end?: number) => T;
|
|
45
|
-
protected readonly length: (what: T) => number;
|
|
46
|
-
|
|
47
|
-
constructor(options: BufferingStreamOptions = {}, concat: (left: T, right: T) => T, slice: (what: T, start?: number, end?: number) => T, length: (what: T) => number) {
|
|
48
|
-
this.emitInterval = options.emitInterval ?? 16; // ms
|
|
49
|
-
this.maxChunkSize = options.maxChunkSize ?? (256 * 1024); // bytes
|
|
50
|
-
this.concat = concat;
|
|
51
|
-
this.slice = slice;
|
|
52
|
-
this.length = length;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
get onData(): Event<T> {
|
|
56
|
-
return this.onDataEmitter.event;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
push(chunk: T): void {
|
|
60
|
-
if (this.buffer) {
|
|
61
|
-
this.buffer = this.concat(this.buffer, chunk);
|
|
62
|
-
} else {
|
|
63
|
-
this.buffer = chunk;
|
|
64
|
-
this.timeout = setTimeout(() => this.emitBufferedChunk(), this.emitInterval);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
dispose(): void {
|
|
69
|
-
clearTimeout(this.timeout);
|
|
70
|
-
this.buffer = undefined;
|
|
71
|
-
this.onDataEmitter.dispose();
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
protected emitBufferedChunk(): void {
|
|
75
|
-
this.onDataEmitter.fire(this.slice(this.buffer!, 0, this.maxChunkSize));
|
|
76
|
-
if (this.length(this.buffer!) <= this.maxChunkSize) {
|
|
77
|
-
this.buffer = undefined;
|
|
78
|
-
} else {
|
|
79
|
-
this.buffer = this.slice(this.buffer!, this.maxChunkSize);
|
|
80
|
-
this.timeout = setTimeout(() => this.emitBufferedChunk(), this.emitInterval);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export class StringBufferingStream extends BufferingStream<string> {
|
|
86
|
-
constructor(options: BufferingStreamOptions = {}) {
|
|
87
|
-
super(options, (left, right) => left.concat(right), (what, start, end) => what.slice(start, end), what => what.length);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export class BufferBufferingStream extends BufferingStream<Buffer> {
|
|
92
|
-
constructor(options: BufferingStreamOptions = {}) {
|
|
93
|
-
super(options, (left, right) => Buffer.concat([left, right]), (what, start, end) => what.slice(start, end), what => what.length);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2022 Ericsson 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 { Emitter, Event } from '@theia/core/lib/common/event';
|
|
18
|
+
|
|
19
|
+
export interface BufferingStreamOptions {
|
|
20
|
+
/**
|
|
21
|
+
* Max size in bytes of the chunks being emitted.
|
|
22
|
+
*/
|
|
23
|
+
maxChunkSize?: number
|
|
24
|
+
/**
|
|
25
|
+
* Amount of time in milliseconds to wait between the moment we start
|
|
26
|
+
* buffering data and when we emit the buffered chunk.
|
|
27
|
+
*/
|
|
28
|
+
emitInterval?: number
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* This component will buffer whatever is pushed to it and emit chunks back
|
|
33
|
+
* every {@link BufferingStreamOptions.emitInterval}. It will also ensure that
|
|
34
|
+
* the emitted chunks never exceed {@link BufferingStreamOptions.maxChunkSize}.
|
|
35
|
+
*/
|
|
36
|
+
export class BufferingStream<T> {
|
|
37
|
+
protected buffer?: T;
|
|
38
|
+
protected timeout?: NodeJS.Timeout;
|
|
39
|
+
protected maxChunkSize: number;
|
|
40
|
+
protected emitInterval: number;
|
|
41
|
+
|
|
42
|
+
protected onDataEmitter = new Emitter<T>();
|
|
43
|
+
protected readonly concat: (left: T, right: T) => T;
|
|
44
|
+
protected readonly slice: (what: T, start?: number, end?: number) => T;
|
|
45
|
+
protected readonly length: (what: T) => number;
|
|
46
|
+
|
|
47
|
+
constructor(options: BufferingStreamOptions = {}, concat: (left: T, right: T) => T, slice: (what: T, start?: number, end?: number) => T, length: (what: T) => number) {
|
|
48
|
+
this.emitInterval = options.emitInterval ?? 16; // ms
|
|
49
|
+
this.maxChunkSize = options.maxChunkSize ?? (256 * 1024); // bytes
|
|
50
|
+
this.concat = concat;
|
|
51
|
+
this.slice = slice;
|
|
52
|
+
this.length = length;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
get onData(): Event<T> {
|
|
56
|
+
return this.onDataEmitter.event;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
push(chunk: T): void {
|
|
60
|
+
if (this.buffer) {
|
|
61
|
+
this.buffer = this.concat(this.buffer, chunk);
|
|
62
|
+
} else {
|
|
63
|
+
this.buffer = chunk;
|
|
64
|
+
this.timeout = setTimeout(() => this.emitBufferedChunk(), this.emitInterval);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
dispose(): void {
|
|
69
|
+
clearTimeout(this.timeout);
|
|
70
|
+
this.buffer = undefined;
|
|
71
|
+
this.onDataEmitter.dispose();
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
protected emitBufferedChunk(): void {
|
|
75
|
+
this.onDataEmitter.fire(this.slice(this.buffer!, 0, this.maxChunkSize));
|
|
76
|
+
if (this.length(this.buffer!) <= this.maxChunkSize) {
|
|
77
|
+
this.buffer = undefined;
|
|
78
|
+
} else {
|
|
79
|
+
this.buffer = this.slice(this.buffer!, this.maxChunkSize);
|
|
80
|
+
this.timeout = setTimeout(() => this.emitBufferedChunk(), this.emitInterval);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export class StringBufferingStream extends BufferingStream<string> {
|
|
86
|
+
constructor(options: BufferingStreamOptions = {}) {
|
|
87
|
+
super(options, (left, right) => left.concat(right), (what, start, end) => what.slice(start, end), what => what.length);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export class BufferBufferingStream extends BufferingStream<Buffer> {
|
|
92
|
+
constructor(options: BufferingStreamOptions = {}) {
|
|
93
|
+
super(options, (left, right) => Buffer.concat([left, right]), (what, start, end) => what.slice(start, end), what => what.length);
|
|
94
|
+
}
|
|
95
|
+
}
|
package/src/node/index.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2017 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
|
-
export * from './terminal-backend-module';
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2017 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
|
+
export * from './terminal-backend-module';
|
|
@@ -1,101 +1,101 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2017 Ericsson 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, named } from '@theia/core/shared/inversify';
|
|
18
|
-
import * as os from 'os';
|
|
19
|
-
import { ILogger } from '@theia/core/lib/common/logger';
|
|
20
|
-
import { TerminalProcess, TerminalProcessOptions, ProcessManager, MultiRingBuffer } from '@theia/process/lib/node';
|
|
21
|
-
import { isWindows, isOSX } from '@theia/core/lib/common';
|
|
22
|
-
import URI from '@theia/core/lib/common/uri';
|
|
23
|
-
import { FileUri } from '@theia/core/lib/
|
|
24
|
-
import { EnvironmentUtils } from '@theia/core/lib/node/environment-utils';
|
|
25
|
-
import { parseArgs } from '@theia/process/lib/node/utils';
|
|
26
|
-
|
|
27
|
-
export const ShellProcessFactory = Symbol('ShellProcessFactory');
|
|
28
|
-
export type ShellProcessFactory = (options: ShellProcessOptions) => ShellProcess;
|
|
29
|
-
|
|
30
|
-
export const ShellProcessOptions = Symbol('ShellProcessOptions');
|
|
31
|
-
export interface ShellProcessOptions {
|
|
32
|
-
shell?: string,
|
|
33
|
-
args?: string[] | string,
|
|
34
|
-
rootURI?: string,
|
|
35
|
-
cols?: number,
|
|
36
|
-
rows?: number,
|
|
37
|
-
env?: { [key: string]: string | null },
|
|
38
|
-
strictEnv?: boolean,
|
|
39
|
-
isPseudo?: boolean,
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export function getRootPath(rootURI?: string): string {
|
|
43
|
-
if (rootURI) {
|
|
44
|
-
const uri = new URI(rootURI);
|
|
45
|
-
return FileUri.fsPath(uri);
|
|
46
|
-
} else {
|
|
47
|
-
return os.homedir();
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
@injectable()
|
|
52
|
-
export class ShellProcess extends TerminalProcess {
|
|
53
|
-
|
|
54
|
-
protected static defaultCols = 80;
|
|
55
|
-
protected static defaultRows = 24;
|
|
56
|
-
|
|
57
|
-
constructor( // eslint-disable-next-line @typescript-eslint/indent
|
|
58
|
-
@inject(ShellProcessOptions) options: ShellProcessOptions,
|
|
59
|
-
@inject(ProcessManager) processManager: ProcessManager,
|
|
60
|
-
@inject(MultiRingBuffer) ringBuffer: MultiRingBuffer,
|
|
61
|
-
@inject(ILogger) @named('terminal') logger: ILogger,
|
|
62
|
-
@inject(EnvironmentUtils) environmentUtils: EnvironmentUtils,
|
|
63
|
-
) {
|
|
64
|
-
super(<TerminalProcessOptions>{
|
|
65
|
-
command: options.shell || ShellProcess.getShellExecutablePath(),
|
|
66
|
-
args: options.args || ShellProcess.getShellExecutableArgs(),
|
|
67
|
-
options: {
|
|
68
|
-
name: 'xterm-color',
|
|
69
|
-
cols: options.cols || ShellProcess.defaultCols,
|
|
70
|
-
rows: options.rows || ShellProcess.defaultRows,
|
|
71
|
-
cwd: getRootPath(options.rootURI),
|
|
72
|
-
env: options.strictEnv !== true ? environmentUtils.mergeProcessEnv(options.env) : options.env,
|
|
73
|
-
},
|
|
74
|
-
isPseudo: options.isPseudo,
|
|
75
|
-
}, processManager, ringBuffer, logger);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
public static getShellExecutablePath(): string {
|
|
79
|
-
const shell = process.env.THEIA_SHELL;
|
|
80
|
-
if (shell) {
|
|
81
|
-
return shell;
|
|
82
|
-
}
|
|
83
|
-
if (isWindows) {
|
|
84
|
-
return 'cmd.exe';
|
|
85
|
-
} else {
|
|
86
|
-
return process.env.SHELL!;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
public static getShellExecutableArgs(): string[] {
|
|
91
|
-
const args = process.env.THEIA_SHELL_ARGS;
|
|
92
|
-
if (args) {
|
|
93
|
-
return parseArgs(args);
|
|
94
|
-
}
|
|
95
|
-
if (isOSX) {
|
|
96
|
-
return ['-l'];
|
|
97
|
-
} else {
|
|
98
|
-
return [];
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2017 Ericsson 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, named } from '@theia/core/shared/inversify';
|
|
18
|
+
import * as os from 'os';
|
|
19
|
+
import { ILogger } from '@theia/core/lib/common/logger';
|
|
20
|
+
import { TerminalProcess, TerminalProcessOptions, ProcessManager, MultiRingBuffer } from '@theia/process/lib/node';
|
|
21
|
+
import { isWindows, isOSX } from '@theia/core/lib/common';
|
|
22
|
+
import URI from '@theia/core/lib/common/uri';
|
|
23
|
+
import { FileUri } from '@theia/core/lib/common/file-uri';
|
|
24
|
+
import { EnvironmentUtils } from '@theia/core/lib/node/environment-utils';
|
|
25
|
+
import { parseArgs } from '@theia/process/lib/node/utils';
|
|
26
|
+
|
|
27
|
+
export const ShellProcessFactory = Symbol('ShellProcessFactory');
|
|
28
|
+
export type ShellProcessFactory = (options: ShellProcessOptions) => ShellProcess;
|
|
29
|
+
|
|
30
|
+
export const ShellProcessOptions = Symbol('ShellProcessOptions');
|
|
31
|
+
export interface ShellProcessOptions {
|
|
32
|
+
shell?: string,
|
|
33
|
+
args?: string[] | string,
|
|
34
|
+
rootURI?: string,
|
|
35
|
+
cols?: number,
|
|
36
|
+
rows?: number,
|
|
37
|
+
env?: { [key: string]: string | null },
|
|
38
|
+
strictEnv?: boolean,
|
|
39
|
+
isPseudo?: boolean,
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function getRootPath(rootURI?: string): string {
|
|
43
|
+
if (rootURI) {
|
|
44
|
+
const uri = new URI(rootURI);
|
|
45
|
+
return FileUri.fsPath(uri);
|
|
46
|
+
} else {
|
|
47
|
+
return os.homedir();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
@injectable()
|
|
52
|
+
export class ShellProcess extends TerminalProcess {
|
|
53
|
+
|
|
54
|
+
protected static defaultCols = 80;
|
|
55
|
+
protected static defaultRows = 24;
|
|
56
|
+
|
|
57
|
+
constructor( // eslint-disable-next-line @typescript-eslint/indent
|
|
58
|
+
@inject(ShellProcessOptions) options: ShellProcessOptions,
|
|
59
|
+
@inject(ProcessManager) processManager: ProcessManager,
|
|
60
|
+
@inject(MultiRingBuffer) ringBuffer: MultiRingBuffer,
|
|
61
|
+
@inject(ILogger) @named('terminal') logger: ILogger,
|
|
62
|
+
@inject(EnvironmentUtils) environmentUtils: EnvironmentUtils,
|
|
63
|
+
) {
|
|
64
|
+
super(<TerminalProcessOptions>{
|
|
65
|
+
command: options.shell || ShellProcess.getShellExecutablePath(),
|
|
66
|
+
args: options.args || ShellProcess.getShellExecutableArgs(),
|
|
67
|
+
options: {
|
|
68
|
+
name: 'xterm-color',
|
|
69
|
+
cols: options.cols || ShellProcess.defaultCols,
|
|
70
|
+
rows: options.rows || ShellProcess.defaultRows,
|
|
71
|
+
cwd: getRootPath(options.rootURI),
|
|
72
|
+
env: options.strictEnv !== true ? environmentUtils.mergeProcessEnv(options.env) : options.env,
|
|
73
|
+
},
|
|
74
|
+
isPseudo: options.isPseudo,
|
|
75
|
+
}, processManager, ringBuffer, logger);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
public static getShellExecutablePath(): string {
|
|
79
|
+
const shell = process.env.THEIA_SHELL;
|
|
80
|
+
if (shell) {
|
|
81
|
+
return shell;
|
|
82
|
+
}
|
|
83
|
+
if (isWindows) {
|
|
84
|
+
return 'cmd.exe';
|
|
85
|
+
} else {
|
|
86
|
+
return process.env.SHELL!;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
public static getShellExecutableArgs(): string[] {
|
|
91
|
+
const args = process.env.THEIA_SHELL_ARGS;
|
|
92
|
+
if (args) {
|
|
93
|
+
return parseArgs(args);
|
|
94
|
+
}
|
|
95
|
+
if (isOSX) {
|
|
96
|
+
return ['-l'];
|
|
97
|
+
} else {
|
|
98
|
+
return [];
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2017 Ericsson 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
|
-
import * as chai from 'chai';
|
|
17
|
-
import { createTerminalTestContainer } from './test/terminal-test-container';
|
|
18
|
-
import { IShellTerminalServer } from '../common/shell-terminal-protocol';
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Globals
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
const expect = chai.expect;
|
|
25
|
-
|
|
26
|
-
describe('ShellServer', function (): void {
|
|
27
|
-
|
|
28
|
-
this.timeout(5000);
|
|
29
|
-
let shellTerminalServer: IShellTerminalServer;
|
|
30
|
-
|
|
31
|
-
beforeEach(() => {
|
|
32
|
-
shellTerminalServer = createTerminalTestContainer().get(IShellTerminalServer);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it('test shell terminal create', async function (): Promise<void> {
|
|
36
|
-
const createResult = shellTerminalServer.create({});
|
|
37
|
-
|
|
38
|
-
expect(await createResult).to.be.greaterThan(-1);
|
|
39
|
-
});
|
|
40
|
-
});
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2017 Ericsson 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
|
+
import * as chai from 'chai';
|
|
17
|
+
import { createTerminalTestContainer } from './test/terminal-test-container';
|
|
18
|
+
import { IShellTerminalServer } from '../common/shell-terminal-protocol';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Globals
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
const expect = chai.expect;
|
|
25
|
+
|
|
26
|
+
describe('ShellServer', function (): void {
|
|
27
|
+
|
|
28
|
+
this.timeout(5000);
|
|
29
|
+
let shellTerminalServer: IShellTerminalServer;
|
|
30
|
+
|
|
31
|
+
beforeEach(() => {
|
|
32
|
+
shellTerminalServer = createTerminalTestContainer().get(IShellTerminalServer);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('test shell terminal create', async function (): Promise<void> {
|
|
36
|
+
const createResult = shellTerminalServer.create({});
|
|
37
|
+
|
|
38
|
+
expect(await createResult).to.be.greaterThan(-1);
|
|
39
|
+
});
|
|
40
|
+
});
|