@codingame/monaco-vscode-xterm-addons-common 24.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. package/empty.js +1 -0
  2. package/package.json +51 -0
  3. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContext.d.ts +25 -0
  4. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContext.js +315 -0
  5. package/vscode/src/vs/workbench/contrib/chat/browser/chatPasteProviders.d.ts +49 -0
  6. package/vscode/src/vs/workbench/contrib/chat/browser/chatPasteProviders.js +379 -0
  7. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/attachInstructionsAction.d.ts +17 -0
  8. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/attachInstructionsAction.js +101 -0
  9. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/newPromptFileActions.d.ts +4 -0
  10. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/newPromptFileActions.js +201 -0
  11. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/askForPromptName.d.ts +7 -0
  12. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/askForPromptName.js +79 -0
  13. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/askForPromptSourceFolder.d.ts +8 -0
  14. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/askForPromptSourceFolder.js +145 -0
  15. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/promptFilePickers.d.ts +73 -0
  16. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/promptFilePickers.js +468 -0
  17. package/vscode/src/vs/workbench/contrib/terminal/browser/terminalUri.d.ts +18 -0
  18. package/vscode/src/vs/workbench/contrib/terminal/browser/terminalUri.js +48 -0
  19. package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/decorationAddon.d.ts +80 -0
  20. package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/decorationAddon.js +583 -0
  21. package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/markNavigationAddon.d.ts +64 -0
  22. package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/markNavigationAddon.js +582 -0
  23. package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/xtermAddonImporter.d.ts +25 -0
  24. package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/xtermAddonImporter.js +43 -0
  25. package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/xtermTerminal.d.ts +187 -0
  26. package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/xtermTerminal.js +867 -0
@@ -0,0 +1,867 @@
1
+
2
+ import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
3
+ import { isAncestorOfActiveElement, getActiveWindow, addDisposableListener, EventType, getWindow, getDocument } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/dom';
4
+ import { IConfigurationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service';
5
+ import { Disposable, MutableDisposable, DisposableStore } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
6
+ import { TerminalSettingId } from '@codingame/monaco-vscode-api/vscode/vs/platform/terminal/common/terminal';
7
+ import { ITerminalLogService } from '@codingame/monaco-vscode-api/vscode/vs/platform/terminal/common/terminal.service';
8
+ import { XtermTerminalConstants } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/terminal/browser/terminal';
9
+ import { ITerminalConfigurationService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/terminal/browser/terminal.service';
10
+ import { LogLevel } from '@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log';
11
+ import { INotificationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/notification/common/notification.service';
12
+ import { MarkNavigationAddon, ScrollPosition } from './markNavigationAddon.js';
13
+ import { localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
14
+ import { IThemeService } from '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/themeService.service';
15
+ import { PANEL_BACKGROUND } from '@codingame/monaco-vscode-api/vscode/vs/workbench/common/theme';
16
+ import { TERMINAL_BACKGROUND_COLOR, TERMINAL_FIND_MATCH_BACKGROUND_COLOR, TERMINAL_FIND_MATCH_BORDER_COLOR, TERMINAL_OVERVIEW_RULER_CURSOR_FOREGROUND_COLOR, TERMINAL_FIND_MATCH_HIGHLIGHT_BACKGROUND_COLOR, TERMINAL_FIND_MATCH_HIGHLIGHT_BORDER_COLOR, TERMINAL_OVERVIEW_RULER_FIND_MATCH_FOREGROUND_COLOR, TERMINAL_FOREGROUND_COLOR, TERMINAL_CURSOR_FOREGROUND_COLOR, TERMINAL_CURSOR_BACKGROUND_COLOR, TERMINAL_SELECTION_BACKGROUND_COLOR, TERMINAL_INACTIVE_SELECTION_BACKGROUND_COLOR, TERMINAL_SELECTION_FOREGROUND_COLOR, ansiColorIdentifiers, TERMINAL_OVERVIEW_RULER_BORDER_COLOR } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/terminal/common/terminalColorRegistry';
17
+ import { ShellIntegrationAddon } from '@codingame/monaco-vscode-api/vscode/vs/platform/terminal/common/xterm/shellIntegrationAddon';
18
+ import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
19
+ import { DecorationAddon } from './decorationAddon.js';
20
+ import { TerminalCapability } from '@codingame/monaco-vscode-api/vscode/vs/platform/terminal/common/capabilities/capabilities';
21
+ import { Emitter } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
22
+ import { ITelemetryService } from '@codingame/monaco-vscode-api/vscode/vs/platform/telemetry/common/telemetry.service';
23
+ import { IContextKeyService } from '@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey.service';
24
+ import { TerminalContextKeys } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/terminal/common/terminalContextKey';
25
+ import { IClipboardService } from '@codingame/monaco-vscode-api/vscode/vs/platform/clipboard/common/clipboardService.service';
26
+ import { debounce } from '@codingame/monaco-vscode-api/vscode/vs/base/common/decorators';
27
+ import { MouseWheelClassifier } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/ui/scrollbar/scrollableElement';
28
+ import { StandardWheelEvent } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/mouseEvent';
29
+ import { ILayoutService } from '@codingame/monaco-vscode-api/vscode/vs/platform/layout/browser/layoutService.service';
30
+ import { AccessibilitySignal } from '@codingame/monaco-vscode-api/vscode/vs/platform/accessibilitySignal/browser/accessibilitySignalService';
31
+ import { IAccessibilitySignalService } from '@codingame/monaco-vscode-api/vscode/vs/platform/accessibilitySignal/browser/accessibilitySignalService.service';
32
+ import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colorUtils';
33
+ import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/baseColors';
34
+ import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/chartsColors';
35
+ import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/editorColors';
36
+ import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/inputColors';
37
+ import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/listColors';
38
+ import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/menuColors';
39
+ import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/minimapColors';
40
+ import { scrollbarSliderHoverBackground, scrollbarSliderBackground, scrollbarSliderActiveBackground } from '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/miscColors';
41
+ import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/quickpickColors';
42
+ import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/searchColors';
43
+ import { XtermAddonImporter } from './xtermAddonImporter.js';
44
+ import { equals } from '@codingame/monaco-vscode-api/vscode/vs/base/common/objects';
45
+ import { assert } from '@codingame/monaco-vscode-api/vscode/vs/base/common/assert';
46
+
47
+ var XtermTerminal_1;
48
+ var RenderConstants;
49
+ (function (RenderConstants) {
50
+ RenderConstants[RenderConstants["SmoothScrollDuration"] = 125] = "SmoothScrollDuration";
51
+ })(RenderConstants || (RenderConstants = {}));
52
+ function getFullBufferLineAsString(lineIndex, buffer) {
53
+ let line = buffer.getLine(lineIndex);
54
+ if (!line) {
55
+ return { lineData: undefined, lineIndex };
56
+ }
57
+ let lineData = line.translateToString(true);
58
+ while (lineIndex > 0 && line.isWrapped) {
59
+ line = buffer.getLine(--lineIndex);
60
+ if (!line) {
61
+ break;
62
+ }
63
+ lineData = line.translateToString(false) + lineData;
64
+ }
65
+ return { lineData, lineIndex };
66
+ }
67
+ let XtermTerminal = class XtermTerminal extends Disposable {
68
+ static { XtermTerminal_1 = this; }
69
+ static { this._suggestedRendererType = undefined; }
70
+ get lastInputEvent() { return this._lastInputEvent; }
71
+ get progressState() { return this._progressState; }
72
+ get findResult() { return this._lastFindResult; }
73
+ get isStdinDisabled() { return !!this.raw.options.disableStdin; }
74
+ get isGpuAccelerated() { return !!this._webglAddon; }
75
+ get markTracker() { return this._markNavigationAddon; }
76
+ get shellIntegration() { return this._shellIntegrationAddon; }
77
+ get decorationAddon() { return this._decorationAddon; }
78
+ get textureAtlas() {
79
+ const canvas = this._webglAddon?.textureAtlas;
80
+ if (!canvas) {
81
+ return undefined;
82
+ }
83
+ return createImageBitmap(canvas);
84
+ }
85
+ get isFocused() {
86
+ if (!this.raw.element) {
87
+ return false;
88
+ }
89
+ return isAncestorOfActiveElement(this.raw.element);
90
+ }
91
+ constructor(resource, xtermCtor, options, _onDidExecuteText, _configurationService, _instantiationService, _logService, _notificationService, _themeService, _telemetryService, _terminalConfigurationService, _clipboardService, contextKeyService, _accessibilitySignalService, layoutService) {
92
+ super();
93
+ this._onDidExecuteText = _onDidExecuteText;
94
+ this._configurationService = _configurationService;
95
+ this._instantiationService = _instantiationService;
96
+ this._logService = _logService;
97
+ this._notificationService = _notificationService;
98
+ this._themeService = _themeService;
99
+ this._telemetryService = _telemetryService;
100
+ this._terminalConfigurationService = _terminalConfigurationService;
101
+ this._clipboardService = _clipboardService;
102
+ this._accessibilitySignalService = _accessibilitySignalService;
103
+ this._isPhysicalMouseWheel = MouseWheelClassifier.INSTANCE.isPhysicalMouseWheel();
104
+ this._progressState = { state: 0, value: 0 };
105
+ this._ligaturesAddon = this._register(( new MutableDisposable()));
106
+ this._attachedDisposables = this._register(( new DisposableStore()));
107
+ this._onDidRequestRunCommand = this._register(( new Emitter()));
108
+ this.onDidRequestRunCommand = this._onDidRequestRunCommand.event;
109
+ this._onDidRequestCopyAsHtml = this._register(( new Emitter()));
110
+ this.onDidRequestCopyAsHtml = this._onDidRequestCopyAsHtml.event;
111
+ this._onDidRequestRefreshDimensions = this._register(( new Emitter()));
112
+ this.onDidRequestRefreshDimensions = this._onDidRequestRefreshDimensions.event;
113
+ this._onDidChangeFindResults = this._register(( new Emitter()));
114
+ this.onDidChangeFindResults = this._onDidChangeFindResults.event;
115
+ this._onDidChangeSelection = this._register(( new Emitter()));
116
+ this.onDidChangeSelection = this._onDidChangeSelection.event;
117
+ this._onDidChangeFocus = this._register(( new Emitter()));
118
+ this.onDidChangeFocus = this._onDidChangeFocus.event;
119
+ this._onDidDispose = this._register(( new Emitter()));
120
+ this.onDidDispose = this._onDidDispose.event;
121
+ this._onDidChangeProgress = this._register(( new Emitter()));
122
+ this.onDidChangeProgress = this._onDidChangeProgress.event;
123
+ this._xtermAddonLoader = options.xtermAddonImporter ?? ( new XtermAddonImporter());
124
+ this._xtermColorProvider = options.xtermColorProvider;
125
+ this._capabilities = options.capabilities;
126
+ const font = this._terminalConfigurationService.getFont(getActiveWindow(), undefined, true);
127
+ const config = this._terminalConfigurationService.config;
128
+ const editorOptions = this._configurationService.getValue('editor');
129
+ this.raw = this._register(( new xtermCtor({
130
+ allowProposedApi: true,
131
+ cols: options.cols,
132
+ rows: options.rows,
133
+ documentOverride: layoutService.mainContainer.ownerDocument,
134
+ altClickMovesCursor: config.altClickMovesCursor && editorOptions.multiCursorModifier === 'alt',
135
+ scrollback: config.scrollback,
136
+ theme: this.getXtermTheme(),
137
+ drawBoldTextInBrightColors: config.drawBoldTextInBrightColors,
138
+ fontFamily: font.fontFamily,
139
+ fontWeight: config.fontWeight,
140
+ fontWeightBold: config.fontWeightBold,
141
+ fontSize: font.fontSize,
142
+ letterSpacing: font.letterSpacing,
143
+ lineHeight: font.lineHeight,
144
+ logLevel: vscodeToXtermLogLevel(this._logService.getLevel()),
145
+ logger: this._logService,
146
+ minimumContrastRatio: config.minimumContrastRatio,
147
+ tabStopWidth: config.tabStopWidth,
148
+ cursorBlink: config.cursorBlinking,
149
+ cursorStyle: vscodeToXtermCursorStyle(config.cursorStyle),
150
+ cursorInactiveStyle: vscodeToXtermCursorStyle(config.cursorStyleInactive),
151
+ cursorWidth: config.cursorWidth,
152
+ macOptionIsMeta: config.macOptionIsMeta,
153
+ macOptionClickForcesSelection: config.macOptionClickForcesSelection,
154
+ rightClickSelectsWord: config.rightClickBehavior === 'selectWord',
155
+ fastScrollModifier: 'alt',
156
+ fastScrollSensitivity: config.fastScrollSensitivity,
157
+ scrollSensitivity: config.mouseWheelScrollSensitivity,
158
+ scrollOnEraseInDisplay: true,
159
+ wordSeparator: config.wordSeparators,
160
+ overviewRuler: options.disableOverviewRuler ? { width: 0 } : {
161
+ width: 14,
162
+ showTopBorder: true,
163
+ },
164
+ ignoreBracketedPasteMode: config.ignoreBracketedPasteMode,
165
+ rescaleOverlappingGlyphs: config.rescaleOverlappingGlyphs,
166
+ windowOptions: {
167
+ getWinSizePixels: true,
168
+ getCellSizePixels: true,
169
+ getWinSizeChars: true,
170
+ },
171
+ })));
172
+ this._updateSmoothScrolling();
173
+ this._core = this.raw._core;
174
+ this._register(this._configurationService.onDidChangeConfiguration(async (e) => {
175
+ if (e.affectsConfiguration(TerminalSettingId.GpuAcceleration)) {
176
+ XtermTerminal_1._suggestedRendererType = undefined;
177
+ }
178
+ if (e.affectsConfiguration('terminal.integrated') || e.affectsConfiguration('editor.fastScrollSensitivity') || e.affectsConfiguration('editor.mouseWheelScrollSensitivity') || e.affectsConfiguration('editor.multiCursorModifier')) {
179
+ this.updateConfig();
180
+ }
181
+ if (e.affectsConfiguration(TerminalSettingId.UnicodeVersion)) {
182
+ this._updateUnicodeVersion();
183
+ }
184
+ if (e.affectsConfiguration(TerminalSettingId.ShellIntegrationDecorationsEnabled)) {
185
+ this._updateTheme();
186
+ }
187
+ }));
188
+ this._register(this._themeService.onDidColorThemeChange(theme => this._updateTheme(theme)));
189
+ this._register(this._logService.onDidChangeLogLevel(e => this.raw.options.logLevel = vscodeToXtermLogLevel(e)));
190
+ this._register(this.raw.onSelectionChange(() => {
191
+ this._onDidChangeSelection.fire();
192
+ if (this.isFocused) {
193
+ this._anyFocusedTerminalHasSelection.set(this.raw.hasSelection());
194
+ }
195
+ }));
196
+ this._register(this.raw.onData(e => this._lastInputEvent = e));
197
+ this._updateUnicodeVersion();
198
+ this._markNavigationAddon = this._instantiationService.createInstance(MarkNavigationAddon, options.capabilities);
199
+ this.raw.loadAddon(this._markNavigationAddon);
200
+ this._decorationAddon = this._instantiationService.createInstance(DecorationAddon, resource, this._capabilities);
201
+ this._register(this._decorationAddon.onDidRequestRunCommand(e => this._onDidRequestRunCommand.fire(e)));
202
+ this._register(this._decorationAddon.onDidRequestCopyAsHtml(e => this._onDidRequestCopyAsHtml.fire(e)));
203
+ this.raw.loadAddon(this._decorationAddon);
204
+ this._shellIntegrationAddon = ( new ShellIntegrationAddon(
205
+ options.shellIntegrationNonce ?? '',
206
+ options.disableShellIntegrationReporting,
207
+ this._onDidExecuteText,
208
+ this._telemetryService,
209
+ this._logService
210
+ ));
211
+ this.raw.loadAddon(this._shellIntegrationAddon);
212
+ this._xtermAddonLoader.importAddon('clipboard').then(ClipboardAddon => {
213
+ if (this._store.isDisposed) {
214
+ return;
215
+ }
216
+ this._clipboardAddon = this._instantiationService.createInstance(ClipboardAddon, undefined, {
217
+ async readText(type) {
218
+ return _clipboardService.readText(type === 'p' ? 'selection' : 'clipboard');
219
+ },
220
+ async writeText(type, text) {
221
+ return _clipboardService.writeText(text, type === 'p' ? 'selection' : 'clipboard');
222
+ }
223
+ });
224
+ this.raw.loadAddon(this._clipboardAddon);
225
+ });
226
+ this._xtermAddonLoader.importAddon('progress').then(ProgressAddon => {
227
+ if (this._store.isDisposed) {
228
+ return;
229
+ }
230
+ const progressAddon = this._instantiationService.createInstance(ProgressAddon);
231
+ this.raw.loadAddon(progressAddon);
232
+ const updateProgress = () => {
233
+ if (!equals(this._progressState, progressAddon.progress)) {
234
+ this._progressState = progressAddon.progress;
235
+ this._onDidChangeProgress.fire(this._progressState);
236
+ }
237
+ };
238
+ this._register(progressAddon.onChange(() => updateProgress()));
239
+ updateProgress();
240
+ const commandDetection = this._capabilities.get(TerminalCapability.CommandDetection);
241
+ if (commandDetection) {
242
+ this._register(commandDetection.onCommandFinished(() => progressAddon.progress = { state: 0, value: 0 }));
243
+ }
244
+ else {
245
+ const disposable = this._capabilities.onDidAddCapability(e => {
246
+ if (e.id === TerminalCapability.CommandDetection) {
247
+ this._register(e.capability.onCommandFinished(() => progressAddon.progress = { state: 0, value: 0 }));
248
+ this._store.delete(disposable);
249
+ }
250
+ });
251
+ this._store.add(disposable);
252
+ }
253
+ });
254
+ this._anyTerminalFocusContextKey = TerminalContextKeys.focusInAny.bindTo(contextKeyService);
255
+ this._anyFocusedTerminalHasSelection = TerminalContextKeys.textSelectedInFocused.bindTo(contextKeyService);
256
+ }
257
+ *getBufferReverseIterator() {
258
+ for (let i = this.raw.buffer.active.length - 1; i >= 0; i--) {
259
+ const { lineData, lineIndex } = getFullBufferLineAsString(i, this.raw.buffer.active);
260
+ if (lineData) {
261
+ i = lineIndex;
262
+ yield lineData;
263
+ }
264
+ }
265
+ }
266
+ getContentsAsText(startMarker, endMarker) {
267
+ const lines = [];
268
+ const buffer = this.raw.buffer.active;
269
+ if (startMarker?.line === -1) {
270
+ throw ( new Error('Cannot get contents of a disposed startMarker'));
271
+ }
272
+ if (endMarker?.line === -1) {
273
+ throw ( new Error('Cannot get contents of a disposed endMarker'));
274
+ }
275
+ const startLine = startMarker?.line ?? 0;
276
+ const endLine = endMarker?.line ?? buffer.length - 1;
277
+ for (let y = startLine; y <= endLine; y++) {
278
+ lines.push(buffer.getLine(y)?.translateToString(true) ?? '');
279
+ }
280
+ return lines.join('\n');
281
+ }
282
+ async getContentsAsHtml() {
283
+ if (!this._serializeAddon) {
284
+ const Addon = await this._xtermAddonLoader.importAddon('serialize');
285
+ this._serializeAddon = ( new Addon());
286
+ this.raw.loadAddon(this._serializeAddon);
287
+ }
288
+ return this._serializeAddon.serializeAsHTML();
289
+ }
290
+ async getCommandOutputAsHtml(command, maxLines) {
291
+ if (!this._serializeAddon) {
292
+ const Addon = await this._xtermAddonLoader.importAddon('serialize');
293
+ this._serializeAddon = ( new Addon());
294
+ this.raw.loadAddon(this._serializeAddon);
295
+ }
296
+ let startLine;
297
+ let startCol;
298
+ if (command.executedMarker && command.executedMarker.line >= 0) {
299
+ startLine = command.executedMarker.line;
300
+ startCol = Math.max(command.executedX ?? 0, 0);
301
+ }
302
+ else {
303
+ startLine = command.marker?.line !== undefined ? command.marker.line + 1 : 1;
304
+ startCol = Math.max(command.startX ?? 0, 0);
305
+ }
306
+ let endLine = command.endMarker?.line !== undefined ? command.endMarker.line - 1 : this.raw.buffer.active.length - 1;
307
+ if (endLine < startLine) {
308
+ return { text: '', truncated: false };
309
+ }
310
+ let emptyLinesFromEnd = 0;
311
+ for (let i = endLine; i >= startLine; i--) {
312
+ const line = this.raw.buffer.active.getLine(i);
313
+ if (line && line.translateToString(true).trim() === '') {
314
+ emptyLinesFromEnd++;
315
+ }
316
+ else {
317
+ break;
318
+ }
319
+ }
320
+ endLine = endLine - emptyLinesFromEnd;
321
+ let emptyLinesFromStart = 0;
322
+ for (let i = startLine; i <= endLine; i++) {
323
+ const line = this.raw.buffer.active.getLine(i);
324
+ if (line && line.translateToString(true, i === startLine ? startCol : undefined).trim() === '') {
325
+ if (i === startLine) {
326
+ startCol = 0;
327
+ }
328
+ emptyLinesFromStart++;
329
+ }
330
+ else {
331
+ break;
332
+ }
333
+ }
334
+ startLine = startLine + emptyLinesFromStart;
335
+ if (maxLines && endLine - startLine > maxLines) {
336
+ startLine = endLine - maxLines;
337
+ startCol = 0;
338
+ }
339
+ const bufferLine = this.raw.buffer.active.getLine(startLine);
340
+ if (bufferLine) {
341
+ startCol = Math.min(startCol, bufferLine.length);
342
+ }
343
+ const range = { startLine, endLine, startCol };
344
+ const result = this._serializeAddon.serializeAsHTML({ range });
345
+ return { text: result, truncated: (endLine - startLine) >= maxLines };
346
+ }
347
+ async getSelectionAsHtml(command) {
348
+ if (!this._serializeAddon) {
349
+ const Addon = await this._xtermAddonLoader.importAddon('serialize');
350
+ this._serializeAddon = ( new Addon());
351
+ this.raw.loadAddon(this._serializeAddon);
352
+ }
353
+ if (command) {
354
+ const length = command.getOutput()?.length;
355
+ const row = command.marker?.line;
356
+ if (!length || !row) {
357
+ throw ( new Error(`No row ${row} or output length ${length} for command ${command}`));
358
+ }
359
+ this.raw.select(0, row + 1, length - Math.floor(length / this.raw.cols));
360
+ }
361
+ const result = this._serializeAddon.serializeAsHTML({ onlySelection: true });
362
+ if (command) {
363
+ this.raw.clearSelection();
364
+ }
365
+ return result;
366
+ }
367
+ attachToElement(container, partialOptions) {
368
+ const options = { enableGpu: true, ...partialOptions };
369
+ if (!this._attached) {
370
+ this.raw.open(container);
371
+ }
372
+ if (options.enableGpu) {
373
+ if (this._shouldLoadWebgl()) {
374
+ this._enableWebglRenderer();
375
+ }
376
+ }
377
+ if (!this.raw.element || !this.raw.textarea) {
378
+ throw ( new Error('xterm elements not set after open'));
379
+ }
380
+ const ad = this._attachedDisposables;
381
+ ad.clear();
382
+ ad.add(addDisposableListener(this.raw.textarea, 'focus', () => this._setFocused(true)));
383
+ ad.add(addDisposableListener(this.raw.textarea, 'blur', () => this._setFocused(false)));
384
+ ad.add(addDisposableListener(this.raw.textarea, 'focusout', () => this._setFocused(false)));
385
+ ad.add(addDisposableListener(this.raw.element, EventType.MOUSE_WHEEL, (e) => {
386
+ const classifier = MouseWheelClassifier.INSTANCE;
387
+ classifier.acceptStandardWheelEvent(( new StandardWheelEvent(e)));
388
+ const value = classifier.isPhysicalMouseWheel();
389
+ if (value !== this._isPhysicalMouseWheel) {
390
+ this._isPhysicalMouseWheel = value;
391
+ this._updateSmoothScrolling();
392
+ }
393
+ }, { passive: true }));
394
+ this._refreshLigaturesAddon();
395
+ this._attached = { container, options };
396
+ return this._attached?.container.querySelector('.xterm-screen');
397
+ }
398
+ _setFocused(isFocused) {
399
+ this._onDidChangeFocus.fire(isFocused);
400
+ this._anyTerminalFocusContextKey.set(isFocused);
401
+ this._anyFocusedTerminalHasSelection.set(isFocused && this.raw.hasSelection());
402
+ }
403
+ write(data, callback) {
404
+ this.raw.write(data, callback);
405
+ }
406
+ resize(columns, rows) {
407
+ this._logService.debug('resizing', columns, rows);
408
+ this.raw.resize(columns, rows);
409
+ }
410
+ updateConfig() {
411
+ const config = this._terminalConfigurationService.config;
412
+ this.raw.options.altClickMovesCursor = config.altClickMovesCursor;
413
+ this._setCursorBlink(config.cursorBlinking);
414
+ this._setCursorStyle(config.cursorStyle);
415
+ this._setCursorStyleInactive(config.cursorStyleInactive);
416
+ this._setCursorWidth(config.cursorWidth);
417
+ this.raw.options.scrollback = config.scrollback;
418
+ this.raw.options.drawBoldTextInBrightColors = config.drawBoldTextInBrightColors;
419
+ this.raw.options.minimumContrastRatio = config.minimumContrastRatio;
420
+ this.raw.options.tabStopWidth = config.tabStopWidth;
421
+ this.raw.options.fastScrollSensitivity = config.fastScrollSensitivity;
422
+ this.raw.options.scrollSensitivity = config.mouseWheelScrollSensitivity;
423
+ this.raw.options.macOptionIsMeta = config.macOptionIsMeta;
424
+ const editorOptions = this._configurationService.getValue('editor');
425
+ this.raw.options.altClickMovesCursor = config.altClickMovesCursor && editorOptions.multiCursorModifier === 'alt';
426
+ this.raw.options.macOptionClickForcesSelection = config.macOptionClickForcesSelection;
427
+ this.raw.options.rightClickSelectsWord = config.rightClickBehavior === 'selectWord';
428
+ this.raw.options.wordSeparator = config.wordSeparators;
429
+ this.raw.options.customGlyphs = config.customGlyphs;
430
+ this.raw.options.ignoreBracketedPasteMode = config.ignoreBracketedPasteMode;
431
+ this.raw.options.rescaleOverlappingGlyphs = config.rescaleOverlappingGlyphs;
432
+ this._updateSmoothScrolling();
433
+ if (this._attached) {
434
+ if (this._attached.options.enableGpu) {
435
+ if (this._shouldLoadWebgl()) {
436
+ this._enableWebglRenderer();
437
+ }
438
+ else {
439
+ this._disposeOfWebglRenderer();
440
+ }
441
+ }
442
+ this._refreshLigaturesAddon();
443
+ }
444
+ }
445
+ _updateSmoothScrolling() {
446
+ this.raw.options.smoothScrollDuration = this._terminalConfigurationService.config.smoothScrolling && this._isPhysicalMouseWheel ? RenderConstants.SmoothScrollDuration : 0;
447
+ }
448
+ _shouldLoadWebgl() {
449
+ return (this._terminalConfigurationService.config.gpuAcceleration === 'auto' && XtermTerminal_1._suggestedRendererType === undefined) || this._terminalConfigurationService.config.gpuAcceleration === 'on';
450
+ }
451
+ forceRedraw() {
452
+ this.raw.clearTextureAtlas();
453
+ }
454
+ clearDecorations() {
455
+ this._decorationAddon?.clearDecorations();
456
+ }
457
+ forceRefresh() {
458
+ this._core.viewport?._innerRefresh();
459
+ }
460
+ async findNext(term, searchOptions) {
461
+ this._updateFindColors(searchOptions);
462
+ return (await this._getSearchAddon()).findNext(term, searchOptions);
463
+ }
464
+ async findPrevious(term, searchOptions) {
465
+ this._updateFindColors(searchOptions);
466
+ return (await this._getSearchAddon()).findPrevious(term, searchOptions);
467
+ }
468
+ _updateFindColors(searchOptions) {
469
+ const theme = this._themeService.getColorTheme();
470
+ const terminalBackground = theme.getColor(TERMINAL_BACKGROUND_COLOR) || theme.getColor(PANEL_BACKGROUND);
471
+ const findMatchBackground = theme.getColor(TERMINAL_FIND_MATCH_BACKGROUND_COLOR);
472
+ const findMatchBorder = theme.getColor(TERMINAL_FIND_MATCH_BORDER_COLOR);
473
+ const findMatchOverviewRuler = theme.getColor(TERMINAL_OVERVIEW_RULER_CURSOR_FOREGROUND_COLOR);
474
+ const findMatchHighlightBackground = theme.getColor(TERMINAL_FIND_MATCH_HIGHLIGHT_BACKGROUND_COLOR);
475
+ const findMatchHighlightBorder = theme.getColor(TERMINAL_FIND_MATCH_HIGHLIGHT_BORDER_COLOR);
476
+ const findMatchHighlightOverviewRuler = theme.getColor(TERMINAL_OVERVIEW_RULER_FIND_MATCH_FOREGROUND_COLOR);
477
+ searchOptions.decorations = {
478
+ activeMatchBackground: findMatchBackground?.toString(),
479
+ activeMatchBorder: findMatchBorder?.toString() || 'transparent',
480
+ activeMatchColorOverviewRuler: findMatchOverviewRuler?.toString() || 'transparent',
481
+ matchBackground: terminalBackground ? findMatchHighlightBackground?.blend(terminalBackground).toString() : undefined,
482
+ matchBorder: findMatchHighlightBorder?.toString() || 'transparent',
483
+ matchOverviewRuler: findMatchHighlightOverviewRuler?.toString() || 'transparent'
484
+ };
485
+ }
486
+ _getSearchAddon() {
487
+ if (!this._searchAddonPromise) {
488
+ this._searchAddonPromise = this._xtermAddonLoader.importAddon('search').then((AddonCtor) => {
489
+ if (this._store.isDisposed) {
490
+ return Promise.reject('Could not create search addon, terminal is disposed');
491
+ }
492
+ this._searchAddon = ( new AddonCtor({ highlightLimit: XtermTerminalConstants.SearchHighlightLimit }));
493
+ this.raw.loadAddon(this._searchAddon);
494
+ this._searchAddon.onDidChangeResults((results) => {
495
+ this._lastFindResult = results;
496
+ this._onDidChangeFindResults.fire(results);
497
+ });
498
+ return this._searchAddon;
499
+ });
500
+ }
501
+ return this._searchAddonPromise;
502
+ }
503
+ clearSearchDecorations() {
504
+ this._searchAddon?.clearDecorations();
505
+ }
506
+ clearActiveSearchDecoration() {
507
+ this._searchAddon?.clearActiveDecoration();
508
+ }
509
+ getFont() {
510
+ return this._terminalConfigurationService.getFont(getWindow(this.raw.element), this._core);
511
+ }
512
+ getLongestViewportWrappedLineLength() {
513
+ let maxLineLength = 0;
514
+ for (let i = this.raw.buffer.active.length - 1; i >= this.raw.buffer.active.viewportY; i--) {
515
+ const lineInfo = this._getWrappedLineCount(i, this.raw.buffer.active);
516
+ maxLineLength = Math.max(maxLineLength, ((lineInfo.lineCount * this.raw.cols) - lineInfo.endSpaces) || 0);
517
+ i = lineInfo.currentIndex;
518
+ }
519
+ return maxLineLength;
520
+ }
521
+ _getWrappedLineCount(index, buffer) {
522
+ let line = buffer.getLine(index);
523
+ if (!line) {
524
+ throw ( new Error('Could not get line'));
525
+ }
526
+ let currentIndex = index;
527
+ let endSpaces = 0;
528
+ for (let i = Math.min(line.length, this.raw.cols) - 1; i >= 0; i--) {
529
+ if (!line?.getCell(i)?.getChars()) {
530
+ endSpaces++;
531
+ }
532
+ else {
533
+ break;
534
+ }
535
+ }
536
+ while (line?.isWrapped && currentIndex > 0) {
537
+ currentIndex--;
538
+ line = buffer.getLine(currentIndex);
539
+ }
540
+ return { lineCount: index - currentIndex + 1, currentIndex, endSpaces };
541
+ }
542
+ scrollDownLine() {
543
+ this.raw.scrollLines(1);
544
+ }
545
+ scrollDownPage() {
546
+ this.raw.scrollPages(1);
547
+ }
548
+ scrollToBottom() {
549
+ this.raw.scrollToBottom();
550
+ }
551
+ scrollUpLine() {
552
+ this.raw.scrollLines(-1);
553
+ }
554
+ scrollUpPage() {
555
+ this.raw.scrollPages(-1);
556
+ }
557
+ scrollToTop() {
558
+ this.raw.scrollToTop();
559
+ }
560
+ scrollToLine(line, position = ScrollPosition.Top) {
561
+ this.markTracker.scrollToLine(line, position);
562
+ }
563
+ clearBuffer() {
564
+ this.raw.clear();
565
+ this._capabilities.get(TerminalCapability.CommandDetection)?.handlePromptStart();
566
+ this._capabilities.get(TerminalCapability.CommandDetection)?.handleCommandStart();
567
+ this._accessibilitySignalService.playSignal(AccessibilitySignal.clear);
568
+ }
569
+ hasSelection() {
570
+ return this.raw.hasSelection();
571
+ }
572
+ clearSelection() {
573
+ this.raw.clearSelection();
574
+ }
575
+ selectMarkedRange(fromMarkerId, toMarkerId, scrollIntoView = false) {
576
+ const detectionCapability = this.shellIntegration.capabilities.get(TerminalCapability.BufferMarkDetection);
577
+ if (!detectionCapability) {
578
+ return;
579
+ }
580
+ const start = detectionCapability.getMark(fromMarkerId);
581
+ const end = detectionCapability.getMark(toMarkerId);
582
+ if (start === undefined || end === undefined) {
583
+ return;
584
+ }
585
+ this.raw.selectLines(start.line, end.line);
586
+ if (scrollIntoView) {
587
+ this.raw.scrollToLine(start.line);
588
+ }
589
+ }
590
+ selectAll() {
591
+ this.raw.focus();
592
+ this.raw.selectAll();
593
+ }
594
+ focus() {
595
+ this.raw.focus();
596
+ }
597
+ async copySelection(asHtml, command) {
598
+ if (this.hasSelection() || (asHtml && command)) {
599
+ if (asHtml) {
600
+ const textAsHtml = await this.getSelectionAsHtml(command);
601
+ function listener(e) {
602
+ if (e.clipboardData) {
603
+ if (!e.clipboardData.types.includes('text/plain')) {
604
+ e.clipboardData.setData('text/plain', command?.getOutput() ?? '');
605
+ }
606
+ e.clipboardData.setData('text/html', textAsHtml);
607
+ }
608
+ e.preventDefault();
609
+ }
610
+ const doc = getDocument(this.raw.element);
611
+ doc.addEventListener('copy', listener);
612
+ doc.execCommand('copy');
613
+ doc.removeEventListener('copy', listener);
614
+ }
615
+ else {
616
+ await this._clipboardService.writeText(this.raw.getSelection());
617
+ }
618
+ }
619
+ else {
620
+ this._notificationService.warn(( localize(11673, 'The terminal has no selection to copy')));
621
+ }
622
+ }
623
+ _setCursorBlink(blink) {
624
+ if (this.raw.options.cursorBlink !== blink) {
625
+ this.raw.options.cursorBlink = blink;
626
+ this.raw.refresh(0, this.raw.rows - 1);
627
+ }
628
+ }
629
+ _setCursorStyle(style) {
630
+ const mapped = vscodeToXtermCursorStyle(style);
631
+ if (this.raw.options.cursorStyle !== mapped) {
632
+ this.raw.options.cursorStyle = mapped;
633
+ }
634
+ }
635
+ _setCursorStyleInactive(style) {
636
+ const mapped = vscodeToXtermCursorStyle(style);
637
+ if (this.raw.options.cursorInactiveStyle !== mapped) {
638
+ this.raw.options.cursorInactiveStyle = mapped;
639
+ }
640
+ }
641
+ _setCursorWidth(width) {
642
+ if (this.raw.options.cursorWidth !== width) {
643
+ this.raw.options.cursorWidth = width;
644
+ }
645
+ }
646
+ async _enableWebglRenderer() {
647
+ if (!this.raw.element || this._webglAddon) {
648
+ return;
649
+ }
650
+ const Addon = await this._xtermAddonLoader.importAddon('webgl');
651
+ this._webglAddon = ( new Addon());
652
+ try {
653
+ this.raw.loadAddon(this._webglAddon);
654
+ this._logService.trace('Webgl was loaded');
655
+ this._webglAddon.onContextLoss(() => {
656
+ this._logService.info(`Webgl lost context, disposing of webgl renderer`);
657
+ this._disposeOfWebglRenderer();
658
+ });
659
+ this._refreshImageAddon();
660
+ this._onDidRequestRefreshDimensions.fire();
661
+ }
662
+ catch (e) {
663
+ this._logService.warn(`Webgl could not be loaded. Falling back to the DOM renderer`, e);
664
+ XtermTerminal_1._suggestedRendererType = 'dom';
665
+ this._disposeOfWebglRenderer();
666
+ }
667
+ }
668
+ async _refreshLigaturesAddon() {
669
+ if (!this.raw.element) {
670
+ return;
671
+ }
672
+ const ligaturesConfig = this._terminalConfigurationService.config.fontLigatures;
673
+ let shouldRecreateWebglRenderer = false;
674
+ if (ligaturesConfig?.enabled) {
675
+ if (this._ligaturesAddon.value && !equals(ligaturesConfig, this._ligaturesAddonConfig)) {
676
+ this._ligaturesAddon.clear();
677
+ }
678
+ if (!this._ligaturesAddon.value) {
679
+ const LigaturesAddon = await this._xtermAddonLoader.importAddon('ligatures');
680
+ if (this._store.isDisposed) {
681
+ return;
682
+ }
683
+ this._ligaturesAddon.value = this._instantiationService.createInstance(LigaturesAddon, {
684
+ fontFeatureSettings: ligaturesConfig.featureSettings,
685
+ fallbackLigatures: ligaturesConfig.fallbackLigatures,
686
+ });
687
+ this.raw.loadAddon(this._ligaturesAddon.value);
688
+ shouldRecreateWebglRenderer = true;
689
+ }
690
+ }
691
+ else {
692
+ if (!this._ligaturesAddon.value) {
693
+ return;
694
+ }
695
+ this._ligaturesAddon.clear();
696
+ shouldRecreateWebglRenderer = true;
697
+ }
698
+ if (shouldRecreateWebglRenderer && this._webglAddon) {
699
+ this._disposeOfWebglRenderer();
700
+ await this._enableWebglRenderer();
701
+ }
702
+ }
703
+ async _refreshImageAddon() {
704
+ if (this._terminalConfigurationService.config.enableImages && this._webglAddon) {
705
+ if (!this._imageAddon) {
706
+ const AddonCtor = await this._xtermAddonLoader.importAddon('image');
707
+ this._imageAddon = ( new AddonCtor());
708
+ this.raw.loadAddon(this._imageAddon);
709
+ }
710
+ }
711
+ else {
712
+ try {
713
+ this._imageAddon?.dispose();
714
+ }
715
+ catch {
716
+ }
717
+ this._imageAddon = undefined;
718
+ }
719
+ }
720
+ _disposeOfWebglRenderer() {
721
+ try {
722
+ this._webglAddon?.dispose();
723
+ }
724
+ catch {
725
+ }
726
+ this._webglAddon = undefined;
727
+ this._refreshImageAddon();
728
+ this._onDidRequestRefreshDimensions.fire();
729
+ }
730
+ async getRangeAsVT(startMarker, endMarker, skipLastLine) {
731
+ if (!this._serializeAddon) {
732
+ const Addon = await this._xtermAddonLoader.importAddon('serialize');
733
+ this._serializeAddon = ( new Addon());
734
+ this.raw.loadAddon(this._serializeAddon);
735
+ }
736
+ assert(startMarker.line !== -1);
737
+ let end = endMarker?.line ?? this.raw.buffer.active.length - 1;
738
+ if (skipLastLine) {
739
+ end = end - 1;
740
+ }
741
+ return this._serializeAddon.serialize({
742
+ range: {
743
+ start: startMarker.line,
744
+ end: end
745
+ }
746
+ });
747
+ }
748
+ getXtermTheme(theme) {
749
+ if (!theme) {
750
+ theme = this._themeService.getColorTheme();
751
+ }
752
+ const config = this._terminalConfigurationService.config;
753
+ const hideOverviewRuler = ['never', 'gutter'].includes(config.shellIntegration?.decorationsEnabled ?? '');
754
+ const foregroundColor = theme.getColor(TERMINAL_FOREGROUND_COLOR);
755
+ const backgroundColor = this._xtermColorProvider.getBackgroundColor(theme);
756
+ const cursorColor = theme.getColor(TERMINAL_CURSOR_FOREGROUND_COLOR) || foregroundColor;
757
+ const cursorAccentColor = theme.getColor(TERMINAL_CURSOR_BACKGROUND_COLOR) || backgroundColor;
758
+ const selectionBackgroundColor = theme.getColor(TERMINAL_SELECTION_BACKGROUND_COLOR);
759
+ const selectionInactiveBackgroundColor = theme.getColor(TERMINAL_INACTIVE_SELECTION_BACKGROUND_COLOR);
760
+ const selectionForegroundColor = theme.getColor(TERMINAL_SELECTION_FOREGROUND_COLOR) || undefined;
761
+ return {
762
+ background: backgroundColor?.toString(),
763
+ foreground: foregroundColor?.toString(),
764
+ cursor: cursorColor?.toString(),
765
+ cursorAccent: cursorAccentColor?.toString(),
766
+ selectionBackground: selectionBackgroundColor?.toString(),
767
+ selectionInactiveBackground: selectionInactiveBackgroundColor?.toString(),
768
+ selectionForeground: selectionForegroundColor?.toString(),
769
+ overviewRulerBorder: hideOverviewRuler ? '#0000' : theme.getColor(TERMINAL_OVERVIEW_RULER_BORDER_COLOR)?.toString(),
770
+ scrollbarSliderActiveBackground: theme.getColor(scrollbarSliderActiveBackground)?.toString(),
771
+ scrollbarSliderBackground: theme.getColor(scrollbarSliderBackground)?.toString(),
772
+ scrollbarSliderHoverBackground: theme.getColor(scrollbarSliderHoverBackground)?.toString(),
773
+ black: theme.getColor(ansiColorIdentifiers[0])?.toString(),
774
+ red: theme.getColor(ansiColorIdentifiers[1])?.toString(),
775
+ green: theme.getColor(ansiColorIdentifiers[2])?.toString(),
776
+ yellow: theme.getColor(ansiColorIdentifiers[3])?.toString(),
777
+ blue: theme.getColor(ansiColorIdentifiers[4])?.toString(),
778
+ magenta: theme.getColor(ansiColorIdentifiers[5])?.toString(),
779
+ cyan: theme.getColor(ansiColorIdentifiers[6])?.toString(),
780
+ white: theme.getColor(ansiColorIdentifiers[7])?.toString(),
781
+ brightBlack: theme.getColor(ansiColorIdentifiers[8])?.toString(),
782
+ brightRed: theme.getColor(ansiColorIdentifiers[9])?.toString(),
783
+ brightGreen: theme.getColor(ansiColorIdentifiers[10])?.toString(),
784
+ brightYellow: theme.getColor(ansiColorIdentifiers[11])?.toString(),
785
+ brightBlue: theme.getColor(ansiColorIdentifiers[12])?.toString(),
786
+ brightMagenta: theme.getColor(ansiColorIdentifiers[13])?.toString(),
787
+ brightCyan: theme.getColor(ansiColorIdentifiers[14])?.toString(),
788
+ brightWhite: theme.getColor(ansiColorIdentifiers[15])?.toString()
789
+ };
790
+ }
791
+ _updateTheme(theme) {
792
+ this.raw.options.theme = this.getXtermTheme(theme);
793
+ }
794
+ refresh() {
795
+ this._updateTheme();
796
+ this._decorationAddon.refreshLayouts();
797
+ }
798
+ async _updateUnicodeVersion() {
799
+ if (!this._unicode11Addon && this._terminalConfigurationService.config.unicodeVersion === '11') {
800
+ const Addon = await this._xtermAddonLoader.importAddon('unicode11');
801
+ this._unicode11Addon = ( new Addon());
802
+ this.raw.loadAddon(this._unicode11Addon);
803
+ }
804
+ if (this.raw.unicode.activeVersion !== this._terminalConfigurationService.config.unicodeVersion) {
805
+ this.raw.unicode.activeVersion = this._terminalConfigurationService.config.unicodeVersion;
806
+ }
807
+ }
808
+ _writeText(data) {
809
+ this.raw.write(data);
810
+ }
811
+ dispose() {
812
+ this._anyTerminalFocusContextKey.reset();
813
+ this._anyFocusedTerminalHasSelection.reset();
814
+ this._onDidDispose.fire();
815
+ super.dispose();
816
+ }
817
+ };
818
+ XtermTerminal.__decorator = ( __decorate([
819
+ debounce(100)
820
+ ], XtermTerminal.prototype, "_refreshLigaturesAddon", null));
821
+ XtermTerminal.__decorator = ( __decorate([
822
+ debounce(100)
823
+ ], XtermTerminal.prototype, "_refreshImageAddon", null));
824
+ XtermTerminal = XtermTerminal_1 = ( __decorate([
825
+ ( __param(4, IConfigurationService)),
826
+ ( __param(5, IInstantiationService)),
827
+ ( __param(6, ITerminalLogService)),
828
+ ( __param(7, INotificationService)),
829
+ ( __param(8, IThemeService)),
830
+ ( __param(9, ITelemetryService)),
831
+ ( __param(10, ITerminalConfigurationService)),
832
+ ( __param(11, IClipboardService)),
833
+ ( __param(12, IContextKeyService)),
834
+ ( __param(13, IAccessibilitySignalService)),
835
+ ( __param(14, ILayoutService))
836
+ ], XtermTerminal));
837
+ function getXtermScaledDimensions(w, font, width, height) {
838
+ if (!font.charWidth || !font.charHeight) {
839
+ return null;
840
+ }
841
+ const scaledWidthAvailable = width * w.devicePixelRatio;
842
+ const scaledCharWidth = font.charWidth * w.devicePixelRatio + font.letterSpacing;
843
+ const cols = Math.max(Math.floor(scaledWidthAvailable / scaledCharWidth), 1);
844
+ const scaledHeightAvailable = height * w.devicePixelRatio;
845
+ const scaledCharHeight = Math.ceil(font.charHeight * w.devicePixelRatio);
846
+ const scaledLineHeight = Math.floor(scaledCharHeight * font.lineHeight);
847
+ const rows = Math.max(Math.floor(scaledHeightAvailable / scaledLineHeight), 1);
848
+ return { rows, cols };
849
+ }
850
+ function vscodeToXtermLogLevel(logLevel) {
851
+ switch (logLevel) {
852
+ case LogLevel.Trace: return 'trace';
853
+ case LogLevel.Debug: return 'debug';
854
+ case LogLevel.Info: return 'info';
855
+ case LogLevel.Warning: return 'warn';
856
+ case LogLevel.Error: return 'error';
857
+ default: return 'off';
858
+ }
859
+ }
860
+ function vscodeToXtermCursorStyle(style) {
861
+ if (style === 'line') {
862
+ return 'bar';
863
+ }
864
+ return style;
865
+ }
866
+
867
+ export { XtermTerminal, getXtermScaledDimensions };