@theia/terminal 1.67.0-next.56 → 1.67.0-next.86

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