@theia/terminal 1.67.0-next.13 → 1.67.0-next.56
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 +1 -1
- package/package.json +11 -10
- package/src/browser/search/terminal-search-widget.tsx +24 -8
- package/src/browser/terminal-frontend-contribution.ts +16 -15
- package/src/browser/terminal-frontend-module.ts +1 -1
- package/src/browser/terminal-widget-impl.ts +10 -4
- package/lib/browser/base/terminal-service.d.ts +0 -35
- package/lib/browser/base/terminal-service.d.ts.map +0 -1
- package/lib/browser/base/terminal-service.js +0 -8
- package/lib/browser/base/terminal-service.js.map +0 -1
- package/lib/browser/base/terminal-widget.d.ts +0 -219
- package/lib/browser/base/terminal-widget.d.ts.map +0 -1
- package/lib/browser/base/terminal-widget.js +0 -35
- package/lib/browser/base/terminal-widget.js.map +0 -1
- package/lib/browser/index.d.ts +0 -2
- package/lib/browser/index.d.ts.map +0 -1
- package/lib/browser/index.js +0 -20
- package/lib/browser/index.js.map +0 -1
- package/lib/browser/search/terminal-search-container.d.ts +0 -4
- package/lib/browser/search/terminal-search-container.d.ts.map +0 -1
- package/lib/browser/search/terminal-search-container.js +0 -29
- package/lib/browser/search/terminal-search-container.js.map +0 -1
- package/lib/browser/search/terminal-search-widget.d.ts +0 -31
- package/lib/browser/search/terminal-search-widget.d.ts.map +0 -1
- package/lib/browser/search/terminal-search-widget.js +0 -140
- package/lib/browser/search/terminal-search-widget.js.map +0 -1
- package/lib/browser/shell-terminal-profile.d.ts +0 -21
- package/lib/browser/shell-terminal-profile.d.ts.map +0 -1
- package/lib/browser/shell-terminal-profile.js +0 -43
- package/lib/browser/shell-terminal-profile.js.map +0 -1
- package/lib/browser/terminal-contribution.d.ts +0 -4
- package/lib/browser/terminal-contribution.d.ts.map +0 -1
- package/lib/browser/terminal-contribution.js +0 -21
- package/lib/browser/terminal-contribution.js.map +0 -1
- package/lib/browser/terminal-copy-on-selection-handler.d.ts +0 -11
- package/lib/browser/terminal-copy-on-selection-handler.d.ts.map +0 -1
- package/lib/browser/terminal-copy-on-selection-handler.js +0 -96
- package/lib/browser/terminal-copy-on-selection-handler.js.map +0 -1
- package/lib/browser/terminal-file-link-provider.d.ts +0 -40
- package/lib/browser/terminal-file-link-provider.d.ts.map +0 -1
- package/lib/browser/terminal-file-link-provider.js +0 -288
- package/lib/browser/terminal-file-link-provider.js.map +0 -1
- package/lib/browser/terminal-frontend-contribution.d.ts +0 -118
- package/lib/browser/terminal-frontend-contribution.d.ts.map +0 -1
- package/lib/browser/terminal-frontend-contribution.js +0 -1086
- package/lib/browser/terminal-frontend-contribution.js.map +0 -1
- package/lib/browser/terminal-frontend-module.d.ts +0 -6
- package/lib/browser/terminal-frontend-module.d.ts.map +0 -1
- package/lib/browser/terminal-frontend-module.js +0 -118
- package/lib/browser/terminal-frontend-module.js.map +0 -1
- package/lib/browser/terminal-link-helpers.d.ts +0 -28
- package/lib/browser/terminal-link-helpers.d.ts.map +0 -1
- package/lib/browser/terminal-link-helpers.js +0 -156
- package/lib/browser/terminal-link-helpers.js.map +0 -1
- package/lib/browser/terminal-link-provider.d.ts +0 -52
- package/lib/browser/terminal-link-provider.d.ts.map +0 -1
- package/lib/browser/terminal-link-provider.js +0 -190
- package/lib/browser/terminal-link-provider.js.map +0 -1
- package/lib/browser/terminal-profile-service.d.ts +0 -59
- package/lib/browser/terminal-profile-service.d.ts.map +0 -1
- package/lib/browser/terminal-profile-service.js +0 -152
- package/lib/browser/terminal-profile-service.js.map +0 -1
- package/lib/browser/terminal-quick-open-service.d.ts +0 -37
- package/lib/browser/terminal-quick-open-service.d.ts.map +0 -1
- package/lib/browser/terminal-quick-open-service.js +0 -130
- package/lib/browser/terminal-quick-open-service.js.map +0 -1
- package/lib/browser/terminal-theme-service.d.ts +0 -12
- package/lib/browser/terminal-theme-service.d.ts.map +0 -1
- package/lib/browser/terminal-theme-service.js +0 -67
- package/lib/browser/terminal-theme-service.js.map +0 -1
- package/lib/browser/terminal-url-link-provider.d.ts +0 -12
- package/lib/browser/terminal-url-link-provider.d.ts.map +0 -1
- package/lib/browser/terminal-url-link-provider.js +0 -69
- package/lib/browser/terminal-url-link-provider.js.map +0 -1
- package/lib/browser/terminal-widget-impl.d.ts +0 -191
- package/lib/browser/terminal-widget-impl.d.ts.map +0 -1
- package/lib/browser/terminal-widget-impl.js +0 -915
- package/lib/browser/terminal-widget-impl.js.map +0 -1
- package/lib/common/base-terminal-protocol.d.ts +0 -56
- package/lib/common/base-terminal-protocol.d.ts.map +0 -1
- package/lib/common/base-terminal-protocol.js +0 -85
- package/lib/common/base-terminal-protocol.js.map +0 -1
- package/lib/common/shell-terminal-protocol.d.ts +0 -67
- package/lib/common/shell-terminal-protocol.d.ts.map +0 -1
- package/lib/common/shell-terminal-protocol.js +0 -36
- package/lib/common/shell-terminal-protocol.js.map +0 -1
- package/lib/common/shell-type.d.ts +0 -23
- package/lib/common/shell-type.d.ts.map +0 -1
- package/lib/common/shell-type.js +0 -66
- package/lib/common/shell-type.js.map +0 -1
- package/lib/common/shell-type.spec.d.ts +0 -2
- package/lib/common/shell-type.spec.d.ts.map +0 -1
- package/lib/common/shell-type.spec.js +0 -159
- package/lib/common/shell-type.spec.js.map +0 -1
- package/lib/common/terminal-preferences.d.ts +0 -74
- package/lib/common/terminal-preferences.d.ts.map +0 -1
- package/lib/common/terminal-preferences.js +0 -516
- package/lib/common/terminal-preferences.js.map +0 -1
- package/lib/common/terminal-protocol.d.ts +0 -13
- package/lib/common/terminal-protocol.d.ts.map +0 -1
- package/lib/common/terminal-protocol.js +0 -22
- package/lib/common/terminal-protocol.js.map +0 -1
- package/lib/common/terminal-watcher.d.ts +0 -14
- package/lib/common/terminal-watcher.d.ts.map +0 -1
- package/lib/common/terminal-watcher.js +0 -66
- package/lib/common/terminal-watcher.js.map +0 -1
- package/lib/node/base-terminal-server.d.ts +0 -25
- package/lib/node/base-terminal-server.d.ts.map +0 -1
- package/lib/node/base-terminal-server.js +0 -158
- package/lib/node/base-terminal-server.js.map +0 -1
- package/lib/node/buffering-stream.d.ts +0 -42
- package/lib/node/buffering-stream.d.ts.map +0 -1
- package/lib/node/buffering-stream.js +0 -76
- package/lib/node/buffering-stream.js.map +0 -1
- package/lib/node/buffering-stream.spec.d.ts +0 -2
- package/lib/node/buffering-stream.spec.d.ts.map +0 -1
- package/lib/node/buffering-stream.spec.js +0 -44
- package/lib/node/buffering-stream.spec.js.map +0 -1
- package/lib/node/index.d.ts +0 -2
- package/lib/node/index.d.ts.map +0 -1
- package/lib/node/index.js +0 -20
- package/lib/node/index.js.map +0 -1
- package/lib/node/shell-process.d.ts +0 -28
- package/lib/node/shell-process.d.ts.map +0 -1
- package/lib/node/shell-process.js +0 -97
- package/lib/node/shell-process.js.map +0 -1
- package/lib/node/shell-terminal-server.d.ts +0 -31
- package/lib/node/shell-terminal-server.d.ts.map +0 -1
- package/lib/node/shell-terminal-server.js +0 -218
- package/lib/node/shell-terminal-server.js.map +0 -1
- package/lib/node/shell-terminal-server.spec.d.ts +0 -2
- package/lib/node/shell-terminal-server.spec.d.ts.map +0 -1
- package/lib/node/shell-terminal-server.spec.js +0 -36
- package/lib/node/shell-terminal-server.spec.js.map +0 -1
- package/lib/node/terminal-backend-contribution.d.ts +0 -10
- package/lib/node/terminal-backend-contribution.d.ts.map +0 -1
- package/lib/node/terminal-backend-contribution.js +0 -68
- package/lib/node/terminal-backend-contribution.js.map +0 -1
- package/lib/node/terminal-backend-contribution.slow-spec.d.ts +0 -2
- package/lib/node/terminal-backend-contribution.slow-spec.d.ts.map +0 -1
- package/lib/node/terminal-backend-contribution.slow-spec.js +0 -55
- package/lib/node/terminal-backend-contribution.slow-spec.js.map +0 -1
- package/lib/node/terminal-backend-module.d.ts +0 -12
- package/lib/node/terminal-backend-module.d.ts.map +0 -1
- package/lib/node/terminal-backend-module.js +0 -70
- package/lib/node/terminal-backend-module.js.map +0 -1
- package/lib/node/terminal-server.d.ts +0 -10
- package/lib/node/terminal-server.d.ts.map +0 -1
- package/lib/node/terminal-server.js +0 -54
- package/lib/node/terminal-server.js.map +0 -1
- package/lib/node/terminal-server.spec.d.ts +0 -2
- package/lib/node/terminal-server.spec.d.ts.map +0 -1
- package/lib/node/terminal-server.spec.js +0 -38
- package/lib/node/terminal-server.spec.js.map +0 -1
- package/lib/node/test/terminal-test-container.d.ts +0 -3
- package/lib/node/test/terminal-test-container.d.ts.map +0 -1
- package/lib/node/test/terminal-test-container.js +0 -41
- package/lib/node/test/terminal-test-container.js.map +0 -1
- package/lib/package.spec.d.ts +0 -1
- package/lib/package.spec.d.ts.map +0 -1
- package/lib/package.spec.js +0 -26
- package/lib/package.spec.js.map +0 -1
|
@@ -1,915 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// *****************************************************************************
|
|
3
|
-
// Copyright (C) 2017 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 TerminalWidgetImpl_1;
|
|
18
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.TerminalWidgetImpl = exports.TerminalContribution = exports.TERMINAL_WIDGET_FACTORY_ID = void 0;
|
|
20
|
-
const tslib_1 = require("tslib");
|
|
21
|
-
const xterm_1 = require("xterm");
|
|
22
|
-
const xterm_addon_fit_1 = require("xterm-addon-fit");
|
|
23
|
-
const inversify_1 = require("@theia/core/shared/inversify");
|
|
24
|
-
const core_1 = require("@theia/core");
|
|
25
|
-
const browser_1 = require("@theia/core/lib/browser");
|
|
26
|
-
const common_1 = require("@theia/core/lib/common");
|
|
27
|
-
const browser_2 = require("@theia/workspace/lib/browser");
|
|
28
|
-
const shell_terminal_protocol_1 = require("../common/shell-terminal-protocol");
|
|
29
|
-
const terminal_protocol_1 = require("../common/terminal-protocol");
|
|
30
|
-
const base_terminal_protocol_1 = require("../common/base-terminal-protocol");
|
|
31
|
-
const terminal_watcher_1 = require("../common/terminal-watcher");
|
|
32
|
-
const terminal_widget_1 = require("./base/terminal-widget");
|
|
33
|
-
const promise_util_1 = require("@theia/core/lib/common/promise-util");
|
|
34
|
-
const terminal_preferences_1 = require("../common/terminal-preferences");
|
|
35
|
-
const uri_1 = require("@theia/core/lib/common/uri");
|
|
36
|
-
const terminal_service_1 = require("./base/terminal-service");
|
|
37
|
-
const terminal_search_widget_1 = require("./search/terminal-search-widget");
|
|
38
|
-
const terminal_copy_on_selection_handler_1 = require("./terminal-copy-on-selection-handler");
|
|
39
|
-
const terminal_theme_service_1 = require("./terminal-theme-service");
|
|
40
|
-
const shell_command_builder_1 = require("@theia/process/lib/common/shell-command-builder");
|
|
41
|
-
const keys_1 = require("@theia/core/lib/browser/keys");
|
|
42
|
-
const nls_1 = require("@theia/core/lib/common/nls");
|
|
43
|
-
const terminal_frontend_contribution_1 = require("./terminal-frontend-contribution");
|
|
44
|
-
const debounce = require("p-debounce");
|
|
45
|
-
const markdown_string_1 = require("@theia/core/lib/common/markdown-rendering/markdown-string");
|
|
46
|
-
const markdown_renderer_1 = require("@theia/core/lib/browser/markdown-rendering/markdown-renderer");
|
|
47
|
-
const service_connection_provider_1 = require("@theia/core/lib/browser/messaging/service-connection-provider");
|
|
48
|
-
const color_registry_1 = require("@theia/core/lib/browser/color-registry");
|
|
49
|
-
const shell_type_1 = require("../common/shell-type");
|
|
50
|
-
exports.TERMINAL_WIDGET_FACTORY_ID = 'terminal';
|
|
51
|
-
exports.TerminalContribution = Symbol('TerminalContribution');
|
|
52
|
-
class TerminalBufferImpl {
|
|
53
|
-
constructor(term) {
|
|
54
|
-
this.term = term;
|
|
55
|
-
}
|
|
56
|
-
get length() {
|
|
57
|
-
return this.term.buffer.active.length;
|
|
58
|
-
}
|
|
59
|
-
;
|
|
60
|
-
getLines(start, length) {
|
|
61
|
-
const result = [];
|
|
62
|
-
for (let i = 0; i < length && this.length - 1 - i >= 0; i++) {
|
|
63
|
-
result.push(this.term.buffer.active.getLine(this.length - 1 - i).translateToString());
|
|
64
|
-
}
|
|
65
|
-
return result;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
let TerminalWidgetImpl = TerminalWidgetImpl_1 = class TerminalWidgetImpl extends terminal_widget_1.TerminalWidget {
|
|
69
|
-
constructor() {
|
|
70
|
-
super(...arguments);
|
|
71
|
-
this.isExtractable = true;
|
|
72
|
-
this.terminalKind = 'user';
|
|
73
|
-
this._terminalId = -1;
|
|
74
|
-
this.onTermDidClose = new core_1.Emitter();
|
|
75
|
-
this.restored = false;
|
|
76
|
-
this.closeOnDispose = true;
|
|
77
|
-
this.isAttachedCloseListener = false;
|
|
78
|
-
this.shown = false;
|
|
79
|
-
this.lastCwd = new uri_1.default();
|
|
80
|
-
this.onDidOpenEmitter = new core_1.Emitter();
|
|
81
|
-
this.onDidOpen = this.onDidOpenEmitter.event;
|
|
82
|
-
this.onDidOpenFailureEmitter = new core_1.Emitter();
|
|
83
|
-
this.onDidOpenFailure = this.onDidOpenFailureEmitter.event;
|
|
84
|
-
this.onSizeChangedEmitter = new core_1.Emitter();
|
|
85
|
-
this.onSizeChanged = this.onSizeChangedEmitter.event;
|
|
86
|
-
this.onDataEmitter = new core_1.Emitter();
|
|
87
|
-
this.onData = this.onDataEmitter.event;
|
|
88
|
-
this.onOutputEmitter = new core_1.Emitter();
|
|
89
|
-
this.onOutput = this.onOutputEmitter.event;
|
|
90
|
-
this.onKeyEmitter = new core_1.Emitter();
|
|
91
|
-
this.onKey = this.onKeyEmitter.event;
|
|
92
|
-
this.onMouseEnterLinkHoverEmitter = new core_1.Emitter();
|
|
93
|
-
this.onMouseEnterLinkHover = this.onMouseEnterLinkHoverEmitter.event;
|
|
94
|
-
this.onMouseLeaveLinkHoverEmitter = new core_1.Emitter();
|
|
95
|
-
this.onMouseLeaveLinkHover = this.onMouseLeaveLinkHoverEmitter.event;
|
|
96
|
-
this.onShellTypeChangedEmiter = new core_1.Emitter();
|
|
97
|
-
this.onShellTypeChanged = this.onShellTypeChangedEmiter.event;
|
|
98
|
-
this.toDisposeOnConnect = new core_1.DisposableCollection();
|
|
99
|
-
this.needsResize = true;
|
|
100
|
-
// Device status code emitted by Xterm.js
|
|
101
|
-
// Check: https://github.com/xtermjs/xterm.js/blob/release/3.14/src/InputHandler.ts#L1055-L1082
|
|
102
|
-
this.deviceStatusCodes = new Set(['\u001B[>0;276;0c', '\u001B[>85;95;0c', '\u001B[>83;40003;0c', '\u001B[?1;2c', '\u001B[?6c']);
|
|
103
|
-
this.termOpened = false;
|
|
104
|
-
this.initialData = '';
|
|
105
|
-
this.resizeTerminal = debounce(() => this.doResizeTerminal(), 50);
|
|
106
|
-
}
|
|
107
|
-
get markdownRenderer() {
|
|
108
|
-
this._markdownRenderer || (this._markdownRenderer = this.markdownRendererFactory());
|
|
109
|
-
return this._markdownRenderer;
|
|
110
|
-
}
|
|
111
|
-
get buffer() {
|
|
112
|
-
return this._buffer;
|
|
113
|
-
}
|
|
114
|
-
init() {
|
|
115
|
-
this.id = this._terminalDOMId;
|
|
116
|
-
this.setTitle(this.options.title || TerminalWidgetImpl_1.LABEL);
|
|
117
|
-
this.setIconClass();
|
|
118
|
-
if (this.options.kind) {
|
|
119
|
-
this.terminalKind = this.options.kind;
|
|
120
|
-
}
|
|
121
|
-
if (this.options.destroyTermOnClose === true) {
|
|
122
|
-
this.toDispose.push(core_1.Disposable.create(() => this.term.dispose()));
|
|
123
|
-
}
|
|
124
|
-
this.location = this.options.location || terminal_widget_1.TerminalLocation.Panel;
|
|
125
|
-
this.title.closable = true;
|
|
126
|
-
this.addClass('terminal-container');
|
|
127
|
-
this.term = new xterm_1.Terminal({
|
|
128
|
-
cursorBlink: this.preferences['terminal.integrated.cursorBlinking'],
|
|
129
|
-
cursorStyle: this.preferences['terminal.integrated.cursorStyle'] === 'line' ? 'bar' : this.preferences['terminal.integrated.cursorStyle'],
|
|
130
|
-
cursorWidth: this.preferences['terminal.integrated.cursorWidth'],
|
|
131
|
-
fontFamily: this.preferences['terminal.integrated.fontFamily'],
|
|
132
|
-
fontSize: this.preferences['terminal.integrated.fontSize'],
|
|
133
|
-
fontWeight: this.preferences['terminal.integrated.fontWeight'],
|
|
134
|
-
fontWeightBold: this.preferences['terminal.integrated.fontWeightBold'],
|
|
135
|
-
drawBoldTextInBrightColors: this.preferences['terminal.integrated.drawBoldTextInBrightColors'],
|
|
136
|
-
letterSpacing: this.preferences['terminal.integrated.letterSpacing'],
|
|
137
|
-
lineHeight: this.preferences['terminal.integrated.lineHeight'],
|
|
138
|
-
scrollback: this.preferences['terminal.integrated.scrollback'],
|
|
139
|
-
fastScrollSensitivity: this.preferences['terminal.integrated.fastScrollSensitivity'],
|
|
140
|
-
theme: this.themeService.theme
|
|
141
|
-
});
|
|
142
|
-
this._buffer = new TerminalBufferImpl(this.term);
|
|
143
|
-
this.fitAddon = new xterm_addon_fit_1.FitAddon();
|
|
144
|
-
this.term.loadAddon(this.fitAddon);
|
|
145
|
-
this.initializeLinkHover();
|
|
146
|
-
this.toDispose.push(this.preferences.onPreferenceChanged(change => {
|
|
147
|
-
this.updateConfig();
|
|
148
|
-
this.needsResize = true;
|
|
149
|
-
this.update();
|
|
150
|
-
}));
|
|
151
|
-
this.toDispose.push(this.themeService.onDidChange(() => {
|
|
152
|
-
this.term.options.theme = this.themeService.theme;
|
|
153
|
-
this.setIconClass();
|
|
154
|
-
}));
|
|
155
|
-
this.attachCustomKeyEventHandler();
|
|
156
|
-
const titleChangeListenerDispose = this.term.onTitleChange((title) => {
|
|
157
|
-
if (this.options.useServerTitle) {
|
|
158
|
-
this.title.label = title;
|
|
159
|
-
}
|
|
160
|
-
});
|
|
161
|
-
this.toDispose.push(titleChangeListenerDispose);
|
|
162
|
-
this.toDispose.push(this.terminalWatcher.onTerminalError(({ terminalId, error, attached }) => {
|
|
163
|
-
if (terminalId === this.terminalId) {
|
|
164
|
-
this.exitStatus = { code: undefined, reason: base_terminal_protocol_1.TerminalExitReason.Process };
|
|
165
|
-
this.logger.error(`The terminal process terminated. Cause: ${error}`);
|
|
166
|
-
if (!attached) {
|
|
167
|
-
this.dispose();
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
}));
|
|
171
|
-
this.toDispose.push(this.terminalWatcher.onTerminalExit(({ terminalId, code, reason, attached }) => {
|
|
172
|
-
if (terminalId === this.terminalId) {
|
|
173
|
-
if (reason) {
|
|
174
|
-
this.exitStatus = { code, reason };
|
|
175
|
-
}
|
|
176
|
-
else {
|
|
177
|
-
this.exitStatus = { code, reason: base_terminal_protocol_1.TerminalExitReason.Process };
|
|
178
|
-
}
|
|
179
|
-
if (!attached) {
|
|
180
|
-
this.dispose();
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
}));
|
|
184
|
-
this.toDispose.push(this.toDisposeOnConnect);
|
|
185
|
-
this.toDispose.push(this.shellTerminalServer.onDidCloseConnection(() => {
|
|
186
|
-
const disposable = this.shellTerminalServer.onDidOpenConnection(() => {
|
|
187
|
-
disposable.dispose();
|
|
188
|
-
this.reconnectTerminalProcess();
|
|
189
|
-
});
|
|
190
|
-
this.toDispose.push(disposable);
|
|
191
|
-
}));
|
|
192
|
-
this.toDispose.push(this.onTermDidClose);
|
|
193
|
-
this.toDispose.push(this.onDidOpenEmitter);
|
|
194
|
-
this.toDispose.push(this.onDidOpenFailureEmitter);
|
|
195
|
-
this.toDispose.push(this.onSizeChangedEmitter);
|
|
196
|
-
this.toDispose.push(this.onDataEmitter);
|
|
197
|
-
this.toDispose.push(this.onKeyEmitter);
|
|
198
|
-
this.toDispose.push(this.onShellTypeChangedEmiter);
|
|
199
|
-
const touchEndListener = (event) => {
|
|
200
|
-
if (this.node.contains(event.target)) {
|
|
201
|
-
this.lastTouchEnd = event;
|
|
202
|
-
}
|
|
203
|
-
};
|
|
204
|
-
document.addEventListener('touchend', touchEndListener, { passive: true });
|
|
205
|
-
this.onDispose(() => {
|
|
206
|
-
document.removeEventListener('touchend', touchEndListener);
|
|
207
|
-
});
|
|
208
|
-
const mouseListener = (event) => {
|
|
209
|
-
this.lastMousePosition = { x: event.x, y: event.y };
|
|
210
|
-
};
|
|
211
|
-
this.node.addEventListener('mousemove', mouseListener);
|
|
212
|
-
this.onDispose(() => {
|
|
213
|
-
this.node.removeEventListener('mousemove', mouseListener);
|
|
214
|
-
});
|
|
215
|
-
const contextMenuListener = (event) => {
|
|
216
|
-
event.preventDefault();
|
|
217
|
-
event.stopPropagation();
|
|
218
|
-
this.contextMenuRenderer.render({ menuPath: terminal_frontend_contribution_1.TerminalMenus.TERMINAL_CONTEXT_MENU, anchor: event, context: this.node });
|
|
219
|
-
};
|
|
220
|
-
this.node.addEventListener('contextmenu', contextMenuListener);
|
|
221
|
-
this.onDispose(() => this.node.removeEventListener('contextmenu', contextMenuListener));
|
|
222
|
-
this.toDispose.push(this.term.onSelectionChange(() => {
|
|
223
|
-
if (this.copyOnSelection) {
|
|
224
|
-
this.copyOnSelectionHandler.copy(this.term.getSelection());
|
|
225
|
-
}
|
|
226
|
-
}));
|
|
227
|
-
this.toDispose.push(this.term.onResize(data => {
|
|
228
|
-
this.onSizeChangedEmitter.fire(data);
|
|
229
|
-
}));
|
|
230
|
-
this.toDispose.push(this.term.onData(data => {
|
|
231
|
-
this.onDataEmitter.fire(data);
|
|
232
|
-
}));
|
|
233
|
-
this.toDispose.push(this.term.onBinary(data => {
|
|
234
|
-
this.onDataEmitter.fire(data);
|
|
235
|
-
}));
|
|
236
|
-
this.toDispose.push(this.term.onKey(data => {
|
|
237
|
-
this.onKeyEmitter.fire(data);
|
|
238
|
-
}));
|
|
239
|
-
for (const contribution of this.terminalContributionProvider.getContributions()) {
|
|
240
|
-
contribution.onCreate(this);
|
|
241
|
-
}
|
|
242
|
-
this.searchBox = this.terminalSearchBoxFactory(this.term);
|
|
243
|
-
this.toDispose.push(this.searchBox);
|
|
244
|
-
}
|
|
245
|
-
get kind() {
|
|
246
|
-
return this.terminalKind;
|
|
247
|
-
}
|
|
248
|
-
updateConfig() {
|
|
249
|
-
this.setCursorBlink(this.preferences.get('terminal.integrated.cursorBlinking'));
|
|
250
|
-
this.setCursorStyle(this.preferences.get('terminal.integrated.cursorStyle'));
|
|
251
|
-
this.setCursorWidth(this.preferences.get('terminal.integrated.cursorWidth'));
|
|
252
|
-
this.term.options.fontFamily = this.preferences.get('terminal.integrated.fontFamily');
|
|
253
|
-
this.term.options.fontSize = this.preferences.get('terminal.integrated.fontSize');
|
|
254
|
-
this.term.options.fontWeight = this.preferences.get('terminal.integrated.fontWeight');
|
|
255
|
-
this.term.options.fontWeightBold = this.preferences.get('terminal.integrated.fontWeightBold');
|
|
256
|
-
this.term.options.drawBoldTextInBrightColors = this.preferences.get('terminal.integrated.drawBoldTextInBrightColors');
|
|
257
|
-
this.term.options.letterSpacing = this.preferences.get('terminal.integrated.letterSpacing');
|
|
258
|
-
this.term.options.lineHeight = this.preferences.get('terminal.integrated.lineHeight');
|
|
259
|
-
this.term.options.scrollback = this.preferences.get('terminal.integrated.scrollback');
|
|
260
|
-
this.term.options.fastScrollSensitivity = this.preferences.get('terminal.integrated.fastScrollSensitivity');
|
|
261
|
-
}
|
|
262
|
-
setIconClass() {
|
|
263
|
-
var _a;
|
|
264
|
-
(_a = this.styleElement) === null || _a === void 0 ? void 0 : _a.remove();
|
|
265
|
-
if (this.options.iconClass) {
|
|
266
|
-
const iconClass = this.options.iconClass;
|
|
267
|
-
if (typeof iconClass === 'string') {
|
|
268
|
-
this.title.iconClass = iconClass;
|
|
269
|
-
}
|
|
270
|
-
else {
|
|
271
|
-
const iconClasses = [];
|
|
272
|
-
iconClasses.push(iconClass.id);
|
|
273
|
-
if (iconClass.color) {
|
|
274
|
-
this.styleElement = browser_1.DecorationStyle.createStyleElement(`${this.terminalId}-terminal-style`);
|
|
275
|
-
const classId = 'terminal-icon-' + (0, core_1.generateUuid)().replace(/-/g, '');
|
|
276
|
-
const color = this.colorRegistry.getCurrentColor(iconClass.color.id);
|
|
277
|
-
this.styleElement.textContent = `
|
|
278
|
-
.${classId}::before {
|
|
279
|
-
color: ${color};
|
|
280
|
-
}
|
|
281
|
-
`;
|
|
282
|
-
iconClasses.push(classId);
|
|
283
|
-
}
|
|
284
|
-
this.title.iconClass = iconClasses.join(' ');
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
setCursorBlink(blink) {
|
|
289
|
-
if (this.term.options.cursorBlink !== blink) {
|
|
290
|
-
this.term.options.cursorBlink = blink;
|
|
291
|
-
this.term.refresh(0, this.term.rows - 1);
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
setCursorStyle(style) {
|
|
295
|
-
if (this.term.options.cursorStyle !== style) {
|
|
296
|
-
this.term.options.cursorStyle = (style === 'line') ? 'bar' : style;
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
setCursorWidth(width) {
|
|
300
|
-
if (this.term.options.cursorWidth !== width) {
|
|
301
|
-
this.term.options.cursorWidth = width;
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
initializeLinkHover() {
|
|
305
|
-
this.linkHover = document.createElement('div');
|
|
306
|
-
this.linkHover.style.position = 'fixed';
|
|
307
|
-
this.linkHover.style.color = 'var(--theia-editorHoverWidget-foreground)';
|
|
308
|
-
this.linkHover.style.backgroundColor = 'var(--theia-editorHoverWidget-background)';
|
|
309
|
-
this.linkHover.style.borderColor = 'var(--theia-editorHoverWidget-border)';
|
|
310
|
-
this.linkHover.style.borderWidth = '0.5px';
|
|
311
|
-
this.linkHover.style.borderStyle = 'solid';
|
|
312
|
-
this.linkHover.style.padding = '5px';
|
|
313
|
-
// Above the xterm.js canvas layers:
|
|
314
|
-
// https://github.com/xtermjs/xterm.js/blob/ff790236c1b205469f17a21246141f512d844295/src/renderer/Renderer.ts#L41-L46
|
|
315
|
-
this.linkHover.style.zIndex = '10';
|
|
316
|
-
// Initially invisible:
|
|
317
|
-
this.linkHover.style.display = 'none';
|
|
318
|
-
this.linkHoverButton = document.createElement('a');
|
|
319
|
-
this.linkHoverButton.textContent = this.linkHoverMessage();
|
|
320
|
-
this.linkHoverButton.style.cursor = 'pointer';
|
|
321
|
-
this.linkHover.appendChild(this.linkHoverButton);
|
|
322
|
-
const cmdCtrl = common_1.isOSX ? 'cmd' : 'ctrl';
|
|
323
|
-
const cmdHint = document.createTextNode(` (${nls_1.nls.localizeByDefault(`${cmdCtrl} + click`)})`);
|
|
324
|
-
this.linkHover.appendChild(cmdHint);
|
|
325
|
-
const onMouseEnter = (mouseEvent) => this.onMouseEnterLinkHoverEmitter.fire(mouseEvent);
|
|
326
|
-
this.linkHover.addEventListener('mouseenter', onMouseEnter);
|
|
327
|
-
this.toDispose.push(core_1.Disposable.create(() => this.linkHover.removeEventListener('mouseenter', onMouseEnter)));
|
|
328
|
-
const onMouseLeave = (mouseEvent) => this.onMouseLeaveLinkHoverEmitter.fire(mouseEvent);
|
|
329
|
-
this.linkHover.addEventListener('mouseleave', onMouseLeave);
|
|
330
|
-
this.toDispose.push(core_1.Disposable.create(() => this.linkHover.removeEventListener('mouseleave', onMouseLeave)));
|
|
331
|
-
this.node.appendChild(this.linkHover);
|
|
332
|
-
}
|
|
333
|
-
showLinkHover(invokeAction, x, y, message) {
|
|
334
|
-
var _a, _b, _c, _d;
|
|
335
|
-
const mouseY = (_b = (_a = this.lastMousePosition) === null || _a === void 0 ? void 0 : _a.y) !== null && _b !== void 0 ? _b : y;
|
|
336
|
-
const mouseX = (_d = (_c = this.lastMousePosition) === null || _c === void 0 ? void 0 : _c.x) !== null && _d !== void 0 ? _d : x;
|
|
337
|
-
this.linkHoverButton.textContent = this.linkHoverMessage(message);
|
|
338
|
-
this.linkHoverButton.onclick = (mouseEvent) => invokeAction(mouseEvent);
|
|
339
|
-
this.linkHover.style.display = 'inline';
|
|
340
|
-
this.linkHover.style.top = `${mouseY - 30}px`;
|
|
341
|
-
this.linkHover.style.left = `${mouseX - 60}px`;
|
|
342
|
-
}
|
|
343
|
-
linkHoverMessage(message) {
|
|
344
|
-
return message !== null && message !== void 0 ? message : nls_1.nls.localizeByDefault('Follow link');
|
|
345
|
-
}
|
|
346
|
-
hideLinkHover() {
|
|
347
|
-
this.linkHover.style.display = 'none';
|
|
348
|
-
// eslint-disable-next-line no-null/no-null
|
|
349
|
-
this.linkHoverButton.onclick = null;
|
|
350
|
-
}
|
|
351
|
-
getTerminal() {
|
|
352
|
-
return this.term;
|
|
353
|
-
}
|
|
354
|
-
getSearchBox() {
|
|
355
|
-
return this.searchBox;
|
|
356
|
-
}
|
|
357
|
-
onCloseRequest(msg) {
|
|
358
|
-
this.exitStatus = { code: undefined, reason: base_terminal_protocol_1.TerminalExitReason.User };
|
|
359
|
-
super.onCloseRequest(msg);
|
|
360
|
-
}
|
|
361
|
-
get dimensions() {
|
|
362
|
-
return {
|
|
363
|
-
cols: this.term.cols,
|
|
364
|
-
rows: this.term.rows,
|
|
365
|
-
};
|
|
366
|
-
}
|
|
367
|
-
get cwd() {
|
|
368
|
-
if (!base_terminal_protocol_1.IBaseTerminalServer.validateId(this.terminalId)) {
|
|
369
|
-
return Promise.reject(new Error('terminal is not started'));
|
|
370
|
-
}
|
|
371
|
-
if (this.terminalService.getById(this.id)) {
|
|
372
|
-
return this.shellTerminalServer.getCwdURI(this.terminalId)
|
|
373
|
-
.then(cwdUrl => {
|
|
374
|
-
this.lastCwd = new uri_1.default(cwdUrl);
|
|
375
|
-
return this.lastCwd;
|
|
376
|
-
}).catch(() => this.lastCwd);
|
|
377
|
-
}
|
|
378
|
-
return Promise.resolve(new uri_1.default());
|
|
379
|
-
}
|
|
380
|
-
get processId() {
|
|
381
|
-
if (!base_terminal_protocol_1.IBaseTerminalServer.validateId(this.terminalId)) {
|
|
382
|
-
return Promise.reject(new Error('terminal is not started'));
|
|
383
|
-
}
|
|
384
|
-
return this.shellTerminalServer.getProcessId(this.terminalId);
|
|
385
|
-
}
|
|
386
|
-
get processInfo() {
|
|
387
|
-
if (!base_terminal_protocol_1.IBaseTerminalServer.validateId(this.terminalId)) {
|
|
388
|
-
return Promise.reject(new Error('terminal is not started'));
|
|
389
|
-
}
|
|
390
|
-
return this.shellTerminalServer.getProcessInfo(this.terminalId);
|
|
391
|
-
}
|
|
392
|
-
get envVarCollectionDescriptionsByExtension() {
|
|
393
|
-
if (!base_terminal_protocol_1.IBaseTerminalServer.validateId(this.terminalId)) {
|
|
394
|
-
return Promise.reject(new Error('terminal is not started'));
|
|
395
|
-
}
|
|
396
|
-
return this.shellTerminalServer.getEnvVarCollectionDescriptionsByExtension(this.terminalId);
|
|
397
|
-
}
|
|
398
|
-
get terminalId() {
|
|
399
|
-
return this._terminalId;
|
|
400
|
-
}
|
|
401
|
-
get lastTouchEndEvent() {
|
|
402
|
-
return this.lastTouchEnd;
|
|
403
|
-
}
|
|
404
|
-
get hiddenFromUser() {
|
|
405
|
-
var _a;
|
|
406
|
-
if (this.shown) {
|
|
407
|
-
return false;
|
|
408
|
-
}
|
|
409
|
-
return (_a = this.options.hideFromUser) !== null && _a !== void 0 ? _a : false;
|
|
410
|
-
}
|
|
411
|
-
get transient() {
|
|
412
|
-
// The terminal is transient if session persistence is disabled or it's explicitly marked as transient
|
|
413
|
-
return !this.preferences['terminal.integrated.enablePersistentSessions'] || !!this.options.isTransient;
|
|
414
|
-
}
|
|
415
|
-
onDispose(onDispose) {
|
|
416
|
-
this.toDispose.push(core_1.Disposable.create(onDispose));
|
|
417
|
-
}
|
|
418
|
-
clearOutput() {
|
|
419
|
-
this.term.clear();
|
|
420
|
-
}
|
|
421
|
-
selectAll() {
|
|
422
|
-
this.term.selectAll();
|
|
423
|
-
}
|
|
424
|
-
async hasChildProcesses() {
|
|
425
|
-
return this.shellTerminalServer.hasChildProcesses(await this.processId);
|
|
426
|
-
}
|
|
427
|
-
storeState() {
|
|
428
|
-
this.closeOnDispose = false;
|
|
429
|
-
if (this.transient || this.options.isPseudoTerminal) {
|
|
430
|
-
return {};
|
|
431
|
-
}
|
|
432
|
-
return { terminalId: this.terminalId, titleLabel: this.title.label };
|
|
433
|
-
}
|
|
434
|
-
restoreState(oldState) {
|
|
435
|
-
// transient terminals and pseudo terminals are not restored
|
|
436
|
-
if (this.transient || this.options.isPseudoTerminal) {
|
|
437
|
-
this.dispose();
|
|
438
|
-
return;
|
|
439
|
-
}
|
|
440
|
-
if (this.restored === false) {
|
|
441
|
-
const state = oldState;
|
|
442
|
-
/* This is a workaround to issue #879 */
|
|
443
|
-
this.restored = true;
|
|
444
|
-
this.title.label = state.titleLabel;
|
|
445
|
-
this.start(state.terminalId);
|
|
446
|
-
}
|
|
447
|
-
}
|
|
448
|
-
/**
|
|
449
|
-
* Create a new shell terminal in the back-end and attach it to a
|
|
450
|
-
* new terminal widget.
|
|
451
|
-
* If id is provided attach to the terminal for this id.
|
|
452
|
-
*/
|
|
453
|
-
async start(id) {
|
|
454
|
-
this._terminalId = typeof id !== 'number' ? await this.createTerminal() : await this.attachTerminal(id);
|
|
455
|
-
this.resizeTerminalProcess();
|
|
456
|
-
this.connectTerminalProcess();
|
|
457
|
-
if (base_terminal_protocol_1.IBaseTerminalServer.validateId(this.terminalId)) {
|
|
458
|
-
this.onDidOpenEmitter.fire(undefined);
|
|
459
|
-
await this.shellTerminalServer.onAttachAttempted(this._terminalId);
|
|
460
|
-
return this.terminalId;
|
|
461
|
-
}
|
|
462
|
-
this.onDidOpenFailureEmitter.fire(undefined);
|
|
463
|
-
throw new Error('Failed to start terminal' + (id ? ` for id: ${id}.` : '.'));
|
|
464
|
-
}
|
|
465
|
-
async attachTerminal(id) {
|
|
466
|
-
const terminalId = await this.shellTerminalServer.attach(id);
|
|
467
|
-
if (base_terminal_protocol_1.IBaseTerminalServer.validateId(terminalId)) {
|
|
468
|
-
// reset exit status if a new terminal process is attached
|
|
469
|
-
this.exitStatus = undefined;
|
|
470
|
-
return terminalId;
|
|
471
|
-
}
|
|
472
|
-
this.logger.warn(`Failed attaching to terminal id ${id}, the terminal is most likely gone. Starting up a new terminal instead.`);
|
|
473
|
-
if (this.kind === 'user') {
|
|
474
|
-
return this.createTerminal();
|
|
475
|
-
}
|
|
476
|
-
else {
|
|
477
|
-
return -1;
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
async createTerminal() {
|
|
481
|
-
var _a, _b;
|
|
482
|
-
let rootURI = (_a = this.options.cwd) === null || _a === void 0 ? void 0 : _a.toString();
|
|
483
|
-
if (!rootURI) {
|
|
484
|
-
const root = (await this.workspaceService.roots)[0];
|
|
485
|
-
rootURI = (_b = root === null || root === void 0 ? void 0 : root.resource) === null || _b === void 0 ? void 0 : _b.toString();
|
|
486
|
-
}
|
|
487
|
-
const { cols, rows } = this.term;
|
|
488
|
-
const terminalId = await this.shellTerminalServer.create({
|
|
489
|
-
shell: this.options.shellPath || this.shellPreferences.shell[core_1.OS.backend.type()],
|
|
490
|
-
args: this.options.shellArgs || this.shellPreferences.shellArgs[core_1.OS.backend.type()],
|
|
491
|
-
env: this.options.env,
|
|
492
|
-
strictEnv: this.options.strictEnv,
|
|
493
|
-
isPseudo: this.options.isPseudoTerminal,
|
|
494
|
-
rootURI,
|
|
495
|
-
cols,
|
|
496
|
-
rows
|
|
497
|
-
});
|
|
498
|
-
if (base_terminal_protocol_1.IBaseTerminalServer.validateId(terminalId)) {
|
|
499
|
-
const processInfo = await this.shellTerminalServer.getProcessInfo(terminalId);
|
|
500
|
-
const shellType = (0, shell_type_1.guessShellTypeFromExecutable)(processInfo.executable);
|
|
501
|
-
if (shellType) {
|
|
502
|
-
this.onShellTypeChangedEmiter.fire(shellType);
|
|
503
|
-
}
|
|
504
|
-
return terminalId;
|
|
505
|
-
}
|
|
506
|
-
throw new Error('Error creating terminal widget, see the backend error log for more information.');
|
|
507
|
-
}
|
|
508
|
-
processMessage(msg) {
|
|
509
|
-
super.processMessage(msg);
|
|
510
|
-
switch (msg.type) {
|
|
511
|
-
case 'fit-request':
|
|
512
|
-
this.onFitRequest(msg);
|
|
513
|
-
break;
|
|
514
|
-
default:
|
|
515
|
-
break;
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
onFitRequest(msg) {
|
|
519
|
-
super.onFitRequest(msg);
|
|
520
|
-
browser_1.MessageLoop.sendMessage(this, browser_1.Widget.ResizeMessage.UnknownSize);
|
|
521
|
-
}
|
|
522
|
-
onActivateRequest(msg) {
|
|
523
|
-
super.onActivateRequest(msg);
|
|
524
|
-
this.term.focus();
|
|
525
|
-
}
|
|
526
|
-
onAfterShow(msg) {
|
|
527
|
-
super.onAfterShow(msg);
|
|
528
|
-
this.update();
|
|
529
|
-
this.shown = true;
|
|
530
|
-
}
|
|
531
|
-
onAfterAttach(msg) {
|
|
532
|
-
browser_1.Widget.attach(this.searchBox, this.node);
|
|
533
|
-
super.onAfterAttach(msg);
|
|
534
|
-
this.update();
|
|
535
|
-
}
|
|
536
|
-
onBeforeDetach(msg) {
|
|
537
|
-
browser_1.Widget.detach(this.searchBox);
|
|
538
|
-
super.onBeforeDetach(msg);
|
|
539
|
-
}
|
|
540
|
-
onResize(msg) {
|
|
541
|
-
super.onResize(msg);
|
|
542
|
-
this.needsResize = true;
|
|
543
|
-
this.update();
|
|
544
|
-
}
|
|
545
|
-
onUpdateRequest(msg) {
|
|
546
|
-
super.onUpdateRequest(msg);
|
|
547
|
-
if (!this.isVisible || !this.isAttached) {
|
|
548
|
-
return;
|
|
549
|
-
}
|
|
550
|
-
this.open();
|
|
551
|
-
if (this.needsResize) {
|
|
552
|
-
this.resizeTerminal();
|
|
553
|
-
this.needsResize = false;
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
connectTerminalProcess() {
|
|
557
|
-
if (typeof this.terminalId !== 'number') {
|
|
558
|
-
return;
|
|
559
|
-
}
|
|
560
|
-
if (this.options.isPseudoTerminal) {
|
|
561
|
-
return;
|
|
562
|
-
}
|
|
563
|
-
this.toDisposeOnConnect.dispose();
|
|
564
|
-
this.toDispose.push(this.toDisposeOnConnect);
|
|
565
|
-
const waitForConnection = this.waitForConnection = new promise_util_1.Deferred();
|
|
566
|
-
this.connectionProvider.listen(`${terminal_protocol_1.terminalsPath}/${this.terminalId}`, (_path, connection) => {
|
|
567
|
-
connection.onMessage(e => {
|
|
568
|
-
this.write(e().readString());
|
|
569
|
-
});
|
|
570
|
-
// Excludes the device status code emitted by Xterm.js
|
|
571
|
-
const sendData = (data) => {
|
|
572
|
-
if (data && !this.deviceStatusCodes.has(data) && !this.disableEnterWhenAttachCloseListener()) {
|
|
573
|
-
connection.getWriteBuffer().writeString(data).commit();
|
|
574
|
-
}
|
|
575
|
-
};
|
|
576
|
-
const disposable = new core_1.DisposableCollection();
|
|
577
|
-
disposable.push(this.term.onData(sendData));
|
|
578
|
-
disposable.push(this.term.onBinary(sendData));
|
|
579
|
-
connection.onClose(() => disposable.dispose());
|
|
580
|
-
if (waitForConnection) {
|
|
581
|
-
waitForConnection.resolve(connection);
|
|
582
|
-
}
|
|
583
|
-
}, false);
|
|
584
|
-
}
|
|
585
|
-
async reconnectTerminalProcess() {
|
|
586
|
-
if (this.options.isPseudoTerminal) {
|
|
587
|
-
return;
|
|
588
|
-
}
|
|
589
|
-
if (typeof this.terminalId === 'number') {
|
|
590
|
-
await this.start(this.terminalId);
|
|
591
|
-
}
|
|
592
|
-
}
|
|
593
|
-
open() {
|
|
594
|
-
if (this.termOpened) {
|
|
595
|
-
return;
|
|
596
|
-
}
|
|
597
|
-
this.term.open(this.node);
|
|
598
|
-
// Workaround for https://github.com/xtermjs/xterm.js/issues/4775. Can be removed for releases > 5.3.0
|
|
599
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
600
|
-
const viewPort = this.term._core.viewport;
|
|
601
|
-
viewPort.register(core_1.Disposable.create(() => {
|
|
602
|
-
if (typeof viewPort._refreshAnimationFrame === 'number') {
|
|
603
|
-
viewPort._coreBrowserService.window.cancelAnimationFrame(viewPort._refreshAnimationFrame);
|
|
604
|
-
}
|
|
605
|
-
}));
|
|
606
|
-
if (browser_1.isFirefox) {
|
|
607
|
-
// monkey patching intersection observer handling for secondary window support
|
|
608
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
609
|
-
const renderService = this.term._core._renderService;
|
|
610
|
-
const originalFunc = renderService._handleIntersectionChange.bind(renderService);
|
|
611
|
-
const replacement = function (entry) {
|
|
612
|
-
if (entry.target.ownerDocument !== document) {
|
|
613
|
-
// in Firefox, the intersection observer always reports the widget as non-intersecting if the dom element
|
|
614
|
-
// is in a different document from when the IntersectionObserver started observing. Since we know
|
|
615
|
-
// that the widget is always "visible" when in a secondary window, so we refresh the rows ourselves
|
|
616
|
-
const patchedEvent = {
|
|
617
|
-
...entry,
|
|
618
|
-
isIntersecting: true,
|
|
619
|
-
};
|
|
620
|
-
originalFunc(patchedEvent);
|
|
621
|
-
}
|
|
622
|
-
else {
|
|
623
|
-
originalFunc(entry);
|
|
624
|
-
}
|
|
625
|
-
};
|
|
626
|
-
renderService._handleIntersectionChange = replacement.bind(renderService);
|
|
627
|
-
}
|
|
628
|
-
if (this.initialData) {
|
|
629
|
-
this.term.write(this.initialData);
|
|
630
|
-
}
|
|
631
|
-
this.termOpened = true;
|
|
632
|
-
this.initialData = '';
|
|
633
|
-
}
|
|
634
|
-
write(data) {
|
|
635
|
-
if (this.termOpened) {
|
|
636
|
-
this.term.write(data);
|
|
637
|
-
this.onOutputEmitter.fire(data);
|
|
638
|
-
}
|
|
639
|
-
else {
|
|
640
|
-
this.initialData += data;
|
|
641
|
-
}
|
|
642
|
-
}
|
|
643
|
-
resize(cols, rows) {
|
|
644
|
-
this.term.resize(cols, rows);
|
|
645
|
-
}
|
|
646
|
-
sendText(text) {
|
|
647
|
-
if (this.waitForConnection) {
|
|
648
|
-
this.waitForConnection.promise.then(connection => connection.getWriteBuffer().writeString(text).commit());
|
|
649
|
-
}
|
|
650
|
-
}
|
|
651
|
-
async executeCommand(commandOptions) {
|
|
652
|
-
this.sendText(this.shellCommandBuilder.buildCommand(await this.processInfo, commandOptions) + core_1.OS.backend.EOL);
|
|
653
|
-
}
|
|
654
|
-
scrollLineUp() {
|
|
655
|
-
this.term.scrollLines(-1);
|
|
656
|
-
}
|
|
657
|
-
scrollLineDown() {
|
|
658
|
-
this.term.scrollLines(1);
|
|
659
|
-
}
|
|
660
|
-
scrollToTop() {
|
|
661
|
-
this.term.scrollToTop();
|
|
662
|
-
}
|
|
663
|
-
scrollToBottom() {
|
|
664
|
-
this.term.scrollToBottom();
|
|
665
|
-
}
|
|
666
|
-
scrollPageUp() {
|
|
667
|
-
this.term.scrollPages(-1);
|
|
668
|
-
}
|
|
669
|
-
scrollPageDown() {
|
|
670
|
-
this.term.scrollPages(1);
|
|
671
|
-
}
|
|
672
|
-
resetTerminal() {
|
|
673
|
-
this.term.reset();
|
|
674
|
-
}
|
|
675
|
-
writeLine(text) {
|
|
676
|
-
this.term.writeln(text);
|
|
677
|
-
this.onOutputEmitter.fire(text + '\n');
|
|
678
|
-
}
|
|
679
|
-
get onTerminalDidClose() {
|
|
680
|
-
return this.onTermDidClose.event;
|
|
681
|
-
}
|
|
682
|
-
dispose() {
|
|
683
|
-
var _a, _b;
|
|
684
|
-
if (this.closeOnDispose === true && typeof this.terminalId === 'number' && !((_a = this.exitStatus) === null || _a === void 0 ? void 0 : _a.code)) {
|
|
685
|
-
// Close the backend terminal only when explicitly closing the terminal
|
|
686
|
-
// a refresh for example won't close it.
|
|
687
|
-
this.shellTerminalServer.close(this.terminalId);
|
|
688
|
-
// Exit status is set when terminal is closed by user or by process, so most likely an extension closed it.
|
|
689
|
-
this.exitStatus = { code: undefined, reason: base_terminal_protocol_1.TerminalExitReason.Extension };
|
|
690
|
-
}
|
|
691
|
-
if (this.exitStatus) {
|
|
692
|
-
this.onTermDidClose.fire(this);
|
|
693
|
-
}
|
|
694
|
-
if (this.enhancedPreviewNode) {
|
|
695
|
-
// don't use preview node anymore. rendered markdown will be disposed on super call
|
|
696
|
-
this.enhancedPreviewNode = undefined;
|
|
697
|
-
}
|
|
698
|
-
(_b = this.styleElement) === null || _b === void 0 ? void 0 : _b.remove();
|
|
699
|
-
super.dispose();
|
|
700
|
-
}
|
|
701
|
-
doResizeTerminal() {
|
|
702
|
-
if (this.isDisposed) {
|
|
703
|
-
return;
|
|
704
|
-
}
|
|
705
|
-
const geo = this.fitAddon.proposeDimensions();
|
|
706
|
-
if (geo) {
|
|
707
|
-
const cols = geo.cols;
|
|
708
|
-
const rows = geo.rows - 1; // subtract one row for margin
|
|
709
|
-
this.term.resize(cols, rows);
|
|
710
|
-
this.resizeTerminalProcess();
|
|
711
|
-
}
|
|
712
|
-
}
|
|
713
|
-
resizeTerminalProcess() {
|
|
714
|
-
if (this.options.isPseudoTerminal) {
|
|
715
|
-
return;
|
|
716
|
-
}
|
|
717
|
-
if (!base_terminal_protocol_1.IBaseTerminalServer.validateId(this.terminalId)
|
|
718
|
-
|| this.exitStatus
|
|
719
|
-
|| !this.terminalService.getById(this.id)) {
|
|
720
|
-
return;
|
|
721
|
-
}
|
|
722
|
-
const { cols, rows } = this.term;
|
|
723
|
-
this.shellTerminalServer.resize(this.terminalId, cols, rows);
|
|
724
|
-
}
|
|
725
|
-
get enableCopy() {
|
|
726
|
-
return this.preferences['terminal.enableCopy'];
|
|
727
|
-
}
|
|
728
|
-
get enablePaste() {
|
|
729
|
-
return this.preferences['terminal.enablePaste'];
|
|
730
|
-
}
|
|
731
|
-
get shellPreferences() {
|
|
732
|
-
var _a, _b, _c;
|
|
733
|
-
return {
|
|
734
|
-
shell: {
|
|
735
|
-
Windows: (_a = this.preferences['terminal.integrated.shell.windows']) !== null && _a !== void 0 ? _a : undefined,
|
|
736
|
-
Linux: (_b = this.preferences['terminal.integrated.shell.linux']) !== null && _b !== void 0 ? _b : undefined,
|
|
737
|
-
OSX: (_c = this.preferences['terminal.integrated.shell.osx']) !== null && _c !== void 0 ? _c : undefined,
|
|
738
|
-
},
|
|
739
|
-
shellArgs: {
|
|
740
|
-
Windows: this.preferences['terminal.integrated.shellArgs.windows'],
|
|
741
|
-
Linux: this.preferences['terminal.integrated.shellArgs.linux'],
|
|
742
|
-
OSX: this.preferences['terminal.integrated.shellArgs.osx'],
|
|
743
|
-
}
|
|
744
|
-
};
|
|
745
|
-
}
|
|
746
|
-
customKeyHandler(event) {
|
|
747
|
-
const keyBindings = browser_1.KeyCode.createKeyCode(event).toString();
|
|
748
|
-
const ctrlCmdCopy = (common_1.isOSX && keyBindings === 'meta+c') || (!common_1.isOSX && keyBindings === 'ctrl+c');
|
|
749
|
-
const ctrlCmdPaste = (common_1.isOSX && keyBindings === 'meta+v') || (!common_1.isOSX && keyBindings === 'ctrl+v');
|
|
750
|
-
if (ctrlCmdCopy && this.enableCopy && this.term.hasSelection()) {
|
|
751
|
-
return false;
|
|
752
|
-
}
|
|
753
|
-
if (ctrlCmdPaste && this.enablePaste) {
|
|
754
|
-
return false;
|
|
755
|
-
}
|
|
756
|
-
return true;
|
|
757
|
-
}
|
|
758
|
-
get copyOnSelection() {
|
|
759
|
-
return this.preferences['terminal.integrated.copyOnSelection'];
|
|
760
|
-
}
|
|
761
|
-
attachCustomKeyEventHandler() {
|
|
762
|
-
this.term.attachCustomKeyEventHandler(e => this.customKeyHandler(e));
|
|
763
|
-
}
|
|
764
|
-
setTitle(title) {
|
|
765
|
-
this.title.caption = title;
|
|
766
|
-
this.title.label = title;
|
|
767
|
-
}
|
|
768
|
-
waitOnExit(waitOnExit) {
|
|
769
|
-
if (waitOnExit) {
|
|
770
|
-
if (typeof waitOnExit === 'string') {
|
|
771
|
-
let message = waitOnExit;
|
|
772
|
-
// Bold the message and add an extra new line to make it stand out from the rest of the output
|
|
773
|
-
message = `\r\n\x1b[1m${message}\x1b[0m`;
|
|
774
|
-
this.write(message);
|
|
775
|
-
}
|
|
776
|
-
this.attachPressEnterKeyToCloseListener(this.term);
|
|
777
|
-
return;
|
|
778
|
-
}
|
|
779
|
-
this.dispose();
|
|
780
|
-
}
|
|
781
|
-
attachPressEnterKeyToCloseListener(term) {
|
|
782
|
-
if (term.textarea) {
|
|
783
|
-
this.isAttachedCloseListener = true;
|
|
784
|
-
this.addKeyListener(term.textarea, keys_1.Key.ENTER, (event) => {
|
|
785
|
-
this.dispose();
|
|
786
|
-
this.isAttachedCloseListener = false;
|
|
787
|
-
});
|
|
788
|
-
}
|
|
789
|
-
}
|
|
790
|
-
disableEnterWhenAttachCloseListener() {
|
|
791
|
-
return this.isAttachedCloseListener;
|
|
792
|
-
}
|
|
793
|
-
getEnhancedPreviewNode() {
|
|
794
|
-
if (this.enhancedPreviewNode) {
|
|
795
|
-
return this.enhancedPreviewNode;
|
|
796
|
-
}
|
|
797
|
-
this.enhancedPreviewNode = document.createElement('div');
|
|
798
|
-
Promise.all([this.envVarCollectionDescriptionsByExtension, this.processId, this.processInfo])
|
|
799
|
-
.then((values) => {
|
|
800
|
-
const extensions = values[0];
|
|
801
|
-
const processId = values[1];
|
|
802
|
-
const processInfo = values[2];
|
|
803
|
-
const markdown = new markdown_string_1.MarkdownStringImpl();
|
|
804
|
-
markdown.appendMarkdown('Process ID: ' + processId + '\\\n');
|
|
805
|
-
markdown.appendMarkdown('Command line: ' +
|
|
806
|
-
processInfo.executable +
|
|
807
|
-
' ' +
|
|
808
|
-
processInfo.arguments.join(' ') +
|
|
809
|
-
'\n\n---\n\n');
|
|
810
|
-
markdown.appendMarkdown('The following extensions have contributed to this terminal\'s environment:\n');
|
|
811
|
-
extensions.forEach((arr, key) => {
|
|
812
|
-
arr.forEach(value => {
|
|
813
|
-
if (value === undefined) {
|
|
814
|
-
markdown.appendMarkdown('* ' + key + '\n');
|
|
815
|
-
}
|
|
816
|
-
else if (typeof value === 'string') {
|
|
817
|
-
markdown.appendMarkdown('* ' + key + ': ' + value + '\n');
|
|
818
|
-
}
|
|
819
|
-
else {
|
|
820
|
-
markdown.appendMarkdown('* ' + key + ': ' + value.value + '\n');
|
|
821
|
-
}
|
|
822
|
-
});
|
|
823
|
-
});
|
|
824
|
-
const enhancedPreviewNode = this.enhancedPreviewNode;
|
|
825
|
-
if (!this.isDisposed && enhancedPreviewNode) {
|
|
826
|
-
const result = this.markdownRenderer.render(markdown);
|
|
827
|
-
this.toDispose.push(result);
|
|
828
|
-
enhancedPreviewNode.appendChild(result.element);
|
|
829
|
-
}
|
|
830
|
-
});
|
|
831
|
-
return this.enhancedPreviewNode;
|
|
832
|
-
}
|
|
833
|
-
};
|
|
834
|
-
exports.TerminalWidgetImpl = TerminalWidgetImpl;
|
|
835
|
-
TerminalWidgetImpl.LABEL = nls_1.nls.localizeByDefault('Terminal');
|
|
836
|
-
tslib_1.__decorate([
|
|
837
|
-
(0, inversify_1.inject)(browser_2.WorkspaceService),
|
|
838
|
-
tslib_1.__metadata("design:type", browser_2.WorkspaceService)
|
|
839
|
-
], TerminalWidgetImpl.prototype, "workspaceService", void 0);
|
|
840
|
-
tslib_1.__decorate([
|
|
841
|
-
(0, inversify_1.inject)(service_connection_provider_1.RemoteConnectionProvider),
|
|
842
|
-
tslib_1.__metadata("design:type", service_connection_provider_1.ServiceConnectionProvider)
|
|
843
|
-
], TerminalWidgetImpl.prototype, "connectionProvider", void 0);
|
|
844
|
-
tslib_1.__decorate([
|
|
845
|
-
(0, inversify_1.inject)(terminal_widget_1.TerminalWidgetOptions),
|
|
846
|
-
tslib_1.__metadata("design:type", Object)
|
|
847
|
-
], TerminalWidgetImpl.prototype, "options", void 0);
|
|
848
|
-
tslib_1.__decorate([
|
|
849
|
-
(0, inversify_1.inject)(shell_terminal_protocol_1.ShellTerminalServerProxy),
|
|
850
|
-
tslib_1.__metadata("design:type", Object)
|
|
851
|
-
], TerminalWidgetImpl.prototype, "shellTerminalServer", void 0);
|
|
852
|
-
tslib_1.__decorate([
|
|
853
|
-
(0, inversify_1.inject)(terminal_watcher_1.TerminalWatcher),
|
|
854
|
-
tslib_1.__metadata("design:type", terminal_watcher_1.TerminalWatcher)
|
|
855
|
-
], TerminalWidgetImpl.prototype, "terminalWatcher", void 0);
|
|
856
|
-
tslib_1.__decorate([
|
|
857
|
-
(0, inversify_1.inject)(core_1.ILogger),
|
|
858
|
-
(0, inversify_1.named)('terminal'),
|
|
859
|
-
tslib_1.__metadata("design:type", Object)
|
|
860
|
-
], TerminalWidgetImpl.prototype, "logger", void 0);
|
|
861
|
-
tslib_1.__decorate([
|
|
862
|
-
(0, inversify_1.inject)('terminal-dom-id'),
|
|
863
|
-
tslib_1.__metadata("design:type", String)
|
|
864
|
-
], TerminalWidgetImpl.prototype, "_terminalDOMId", void 0);
|
|
865
|
-
tslib_1.__decorate([
|
|
866
|
-
(0, inversify_1.inject)(terminal_preferences_1.TerminalPreferences),
|
|
867
|
-
tslib_1.__metadata("design:type", Object)
|
|
868
|
-
], TerminalWidgetImpl.prototype, "preferences", void 0);
|
|
869
|
-
tslib_1.__decorate([
|
|
870
|
-
(0, inversify_1.inject)(core_1.ContributionProvider),
|
|
871
|
-
(0, inversify_1.named)(exports.TerminalContribution),
|
|
872
|
-
tslib_1.__metadata("design:type", Object)
|
|
873
|
-
], TerminalWidgetImpl.prototype, "terminalContributionProvider", void 0);
|
|
874
|
-
tslib_1.__decorate([
|
|
875
|
-
(0, inversify_1.inject)(terminal_service_1.TerminalService),
|
|
876
|
-
tslib_1.__metadata("design:type", Object)
|
|
877
|
-
], TerminalWidgetImpl.prototype, "terminalService", void 0);
|
|
878
|
-
tslib_1.__decorate([
|
|
879
|
-
(0, inversify_1.inject)(terminal_search_widget_1.TerminalSearchWidgetFactory),
|
|
880
|
-
tslib_1.__metadata("design:type", Function)
|
|
881
|
-
], TerminalWidgetImpl.prototype, "terminalSearchBoxFactory", void 0);
|
|
882
|
-
tslib_1.__decorate([
|
|
883
|
-
(0, inversify_1.inject)(terminal_copy_on_selection_handler_1.TerminalCopyOnSelectionHandler),
|
|
884
|
-
tslib_1.__metadata("design:type", terminal_copy_on_selection_handler_1.TerminalCopyOnSelectionHandler)
|
|
885
|
-
], TerminalWidgetImpl.prototype, "copyOnSelectionHandler", void 0);
|
|
886
|
-
tslib_1.__decorate([
|
|
887
|
-
(0, inversify_1.inject)(terminal_theme_service_1.TerminalThemeService),
|
|
888
|
-
tslib_1.__metadata("design:type", terminal_theme_service_1.TerminalThemeService)
|
|
889
|
-
], TerminalWidgetImpl.prototype, "themeService", void 0);
|
|
890
|
-
tslib_1.__decorate([
|
|
891
|
-
(0, inversify_1.inject)(color_registry_1.ColorRegistry),
|
|
892
|
-
tslib_1.__metadata("design:type", color_registry_1.ColorRegistry)
|
|
893
|
-
], TerminalWidgetImpl.prototype, "colorRegistry", void 0);
|
|
894
|
-
tslib_1.__decorate([
|
|
895
|
-
(0, inversify_1.inject)(shell_command_builder_1.ShellCommandBuilder),
|
|
896
|
-
tslib_1.__metadata("design:type", shell_command_builder_1.ShellCommandBuilder)
|
|
897
|
-
], TerminalWidgetImpl.prototype, "shellCommandBuilder", void 0);
|
|
898
|
-
tslib_1.__decorate([
|
|
899
|
-
(0, inversify_1.inject)(browser_1.ContextMenuRenderer),
|
|
900
|
-
tslib_1.__metadata("design:type", browser_1.ContextMenuRenderer)
|
|
901
|
-
], TerminalWidgetImpl.prototype, "contextMenuRenderer", void 0);
|
|
902
|
-
tslib_1.__decorate([
|
|
903
|
-
(0, inversify_1.inject)(markdown_renderer_1.MarkdownRendererFactory),
|
|
904
|
-
tslib_1.__metadata("design:type", Function)
|
|
905
|
-
], TerminalWidgetImpl.prototype, "markdownRendererFactory", void 0);
|
|
906
|
-
tslib_1.__decorate([
|
|
907
|
-
(0, inversify_1.postConstruct)(),
|
|
908
|
-
tslib_1.__metadata("design:type", Function),
|
|
909
|
-
tslib_1.__metadata("design:paramtypes", []),
|
|
910
|
-
tslib_1.__metadata("design:returntype", void 0)
|
|
911
|
-
], TerminalWidgetImpl.prototype, "init", null);
|
|
912
|
-
exports.TerminalWidgetImpl = TerminalWidgetImpl = TerminalWidgetImpl_1 = tslib_1.__decorate([
|
|
913
|
-
(0, inversify_1.injectable)()
|
|
914
|
-
], TerminalWidgetImpl);
|
|
915
|
-
//# sourceMappingURL=terminal-widget-impl.js.map
|