@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,582 @@
1
+
2
+ import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
3
+ import { coalesce } from '@codingame/monaco-vscode-api/vscode/vs/base/common/arrays';
4
+ import { Disposable, MutableDisposable, dispose, DisposableStore } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
5
+ import { TerminalCapability } from '@codingame/monaco-vscode-api/vscode/vs/platform/terminal/common/capabilities/capabilities';
6
+ import { timeout } from '@codingame/monaco-vscode-api/vscode/vs/base/common/async';
7
+ import { IThemeService } from '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/themeService.service';
8
+ import { TERMINAL_OVERVIEW_RULER_CURSOR_FOREGROUND_COLOR } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/terminal/common/terminalColorRegistry';
9
+ import { getWindow } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/dom';
10
+ import { isFullTerminalCommand } from '@codingame/monaco-vscode-api/vscode/vs/platform/terminal/common/capabilities/commandDetection/terminalCommand';
11
+ import { IConfigurationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service';
12
+ import { TerminalContribSettingId } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/terminal/terminalContribExports';
13
+
14
+ var Boundary;
15
+ (function (Boundary) {
16
+ Boundary[Boundary["Top"] = 0] = "Top";
17
+ Boundary[Boundary["Bottom"] = 1] = "Bottom";
18
+ })(Boundary || (Boundary = {}));
19
+ var ScrollPosition;
20
+ (function (ScrollPosition) {
21
+ ScrollPosition[ScrollPosition["Top"] = 0] = "Top";
22
+ ScrollPosition[ScrollPosition["Middle"] = 1] = "Middle";
23
+ })(ScrollPosition || (ScrollPosition = {}));
24
+ let MarkNavigationAddon = class MarkNavigationAddon extends Disposable {
25
+ activate(terminal) {
26
+ this._terminal = terminal;
27
+ this._register(this._terminal.onData(() => {
28
+ this._currentMarker = Boundary.Bottom;
29
+ }));
30
+ }
31
+ constructor(_capabilities, _configurationService, _themeService) {
32
+ super();
33
+ this._capabilities = _capabilities;
34
+ this._configurationService = _configurationService;
35
+ this._themeService = _themeService;
36
+ this._currentMarker = Boundary.Bottom;
37
+ this._selectionStart = null;
38
+ this._isDisposable = false;
39
+ this._commandGuideDecorations = this._register(( new MutableDisposable()));
40
+ }
41
+ _getMarkers(skipEmptyCommands) {
42
+ const commandCapability = this._capabilities.get(TerminalCapability.CommandDetection);
43
+ const partialCommandCapability = this._capabilities.get(TerminalCapability.PartialCommandDetection);
44
+ const markCapability = this._capabilities.get(TerminalCapability.BufferMarkDetection);
45
+ let markers = [];
46
+ if (commandCapability) {
47
+ markers = coalesce(( commandCapability.commands.filter(e => skipEmptyCommands ? e.exitCode !== undefined : true).map(e => e.promptStartMarker ?? e.marker)));
48
+ if (commandCapability.currentCommand?.promptStartMarker && commandCapability.currentCommand.commandExecutedMarker) {
49
+ markers.push(commandCapability.currentCommand?.promptStartMarker);
50
+ }
51
+ }
52
+ else if (partialCommandCapability) {
53
+ markers.push(...partialCommandCapability.commands);
54
+ }
55
+ if (markCapability && !skipEmptyCommands) {
56
+ let next = markCapability.markers().next()?.value;
57
+ const arr = [];
58
+ while (next) {
59
+ arr.push(next);
60
+ next = markCapability.markers().next()?.value;
61
+ }
62
+ markers = arr;
63
+ }
64
+ return markers;
65
+ }
66
+ _findCommand(marker) {
67
+ const commandCapability = this._capabilities.get(TerminalCapability.CommandDetection);
68
+ if (commandCapability) {
69
+ const command = commandCapability.commands.find(e => e.marker?.line === marker.line || e.promptStartMarker?.line === marker.line);
70
+ if (command) {
71
+ return command;
72
+ }
73
+ if (commandCapability.currentCommand) {
74
+ return commandCapability.currentCommand;
75
+ }
76
+ }
77
+ return undefined;
78
+ }
79
+ clear() {
80
+ this._currentMarker = Boundary.Bottom;
81
+ this._resetNavigationDecorations();
82
+ this._selectionStart = null;
83
+ }
84
+ _resetNavigationDecorations() {
85
+ if (this._navigationDecorations) {
86
+ dispose(this._navigationDecorations);
87
+ }
88
+ this._navigationDecorations = [];
89
+ }
90
+ _isEmptyCommand(marker) {
91
+ if (marker === Boundary.Bottom) {
92
+ return true;
93
+ }
94
+ if (marker === Boundary.Top) {
95
+ return !( this._getMarkers(true).map(e => e.line)).includes(0);
96
+ }
97
+ return !this._getMarkers(true).includes(marker);
98
+ }
99
+ scrollToPreviousMark(scrollPosition = ScrollPosition.Middle, retainSelection = false, skipEmptyCommands = true) {
100
+ if (!this._terminal) {
101
+ return;
102
+ }
103
+ if (!retainSelection) {
104
+ this._selectionStart = null;
105
+ }
106
+ let markerIndex;
107
+ const currentLineY = typeof this._currentMarker === 'object'
108
+ ? this.getTargetScrollLine(this._currentMarker.line, scrollPosition)
109
+ : Math.min(getLine(this._terminal, this._currentMarker), this._terminal.buffer.active.baseY);
110
+ const viewportY = this._terminal.buffer.active.viewportY;
111
+ if (typeof this._currentMarker === 'object' ? !this._isMarkerInViewport(this._terminal, this._currentMarker) : currentLineY !== viewportY) {
112
+ const markersBelowViewport = this._getMarkers(skipEmptyCommands).filter(e => e.line >= viewportY).length;
113
+ markerIndex = this._getMarkers(skipEmptyCommands).length - markersBelowViewport - 1;
114
+ }
115
+ else if (this._currentMarker === Boundary.Bottom) {
116
+ markerIndex = this._getMarkers(skipEmptyCommands).length - 1;
117
+ }
118
+ else if (this._currentMarker === Boundary.Top) {
119
+ markerIndex = -1;
120
+ }
121
+ else if (this._isDisposable) {
122
+ markerIndex = this._findPreviousMarker(skipEmptyCommands);
123
+ this._currentMarker.dispose();
124
+ this._isDisposable = false;
125
+ }
126
+ else {
127
+ if (skipEmptyCommands && this._isEmptyCommand(this._currentMarker)) {
128
+ markerIndex = this._findPreviousMarker(true);
129
+ }
130
+ else {
131
+ markerIndex = this._getMarkers(skipEmptyCommands).indexOf(this._currentMarker) - 1;
132
+ }
133
+ }
134
+ if (markerIndex < 0) {
135
+ this._currentMarker = Boundary.Top;
136
+ this._terminal.scrollToTop();
137
+ this._resetNavigationDecorations();
138
+ return;
139
+ }
140
+ this._currentMarker = this._getMarkers(skipEmptyCommands)[markerIndex];
141
+ this._scrollToCommand(this._currentMarker, scrollPosition);
142
+ }
143
+ scrollToNextMark(scrollPosition = ScrollPosition.Middle, retainSelection = false, skipEmptyCommands = true) {
144
+ if (!this._terminal) {
145
+ return;
146
+ }
147
+ if (!retainSelection) {
148
+ this._selectionStart = null;
149
+ }
150
+ let markerIndex;
151
+ const currentLineY = typeof this._currentMarker === 'object'
152
+ ? this.getTargetScrollLine(this._currentMarker.line, scrollPosition)
153
+ : Math.min(getLine(this._terminal, this._currentMarker), this._terminal.buffer.active.baseY);
154
+ const viewportY = this._terminal.buffer.active.viewportY;
155
+ if (typeof this._currentMarker === 'object' ? !this._isMarkerInViewport(this._terminal, this._currentMarker) : currentLineY !== viewportY) {
156
+ const markersAboveViewport = this._getMarkers(skipEmptyCommands).filter(e => e.line <= viewportY).length;
157
+ markerIndex = markersAboveViewport;
158
+ }
159
+ else if (this._currentMarker === Boundary.Bottom) {
160
+ markerIndex = this._getMarkers(skipEmptyCommands).length;
161
+ }
162
+ else if (this._currentMarker === Boundary.Top) {
163
+ markerIndex = 0;
164
+ }
165
+ else if (this._isDisposable) {
166
+ markerIndex = this._findNextMarker(skipEmptyCommands);
167
+ this._currentMarker.dispose();
168
+ this._isDisposable = false;
169
+ }
170
+ else {
171
+ if (skipEmptyCommands && this._isEmptyCommand(this._currentMarker)) {
172
+ markerIndex = this._findNextMarker(true);
173
+ }
174
+ else {
175
+ markerIndex = this._getMarkers(skipEmptyCommands).indexOf(this._currentMarker) + 1;
176
+ }
177
+ }
178
+ if (markerIndex >= this._getMarkers(skipEmptyCommands).length) {
179
+ this._currentMarker = Boundary.Bottom;
180
+ this._terminal.scrollToBottom();
181
+ this._resetNavigationDecorations();
182
+ return;
183
+ }
184
+ this._currentMarker = this._getMarkers(skipEmptyCommands)[markerIndex];
185
+ this._scrollToCommand(this._currentMarker, scrollPosition);
186
+ }
187
+ _scrollToCommand(marker, position) {
188
+ const command = this._findCommand(marker);
189
+ if (command) {
190
+ this.revealCommand(command, position);
191
+ }
192
+ else {
193
+ this._scrollToMarker(marker, position);
194
+ }
195
+ }
196
+ _scrollToMarker(start, position, end, options) {
197
+ if (!this._terminal) {
198
+ return;
199
+ }
200
+ if (!this._isMarkerInViewport(this._terminal, start) || options?.forceScroll) {
201
+ const line = this.getTargetScrollLine(toLineIndex(start), position);
202
+ this._terminal.scrollToLine(line);
203
+ }
204
+ if (!options?.hideDecoration) {
205
+ if (options?.bufferRange) {
206
+ this._highlightBufferRange(options.bufferRange);
207
+ }
208
+ else {
209
+ this.registerTemporaryDecoration(start, end, true);
210
+ }
211
+ }
212
+ }
213
+ _createMarkerForOffset(marker, offset) {
214
+ if (offset === 0 && isMarker(marker)) {
215
+ return marker;
216
+ }
217
+ else {
218
+ const offsetMarker = this._terminal?.registerMarker(-this._terminal.buffer.active.cursorY + toLineIndex(marker) - this._terminal.buffer.active.baseY + offset);
219
+ if (offsetMarker) {
220
+ return offsetMarker;
221
+ }
222
+ else {
223
+ throw ( new Error(`Could not register marker with offset ${toLineIndex(marker)}, ${offset}`));
224
+ }
225
+ }
226
+ }
227
+ revealCommand(command, position = ScrollPosition.Middle) {
228
+ const marker = isFullTerminalCommand(command) ? command.marker : command.commandStartMarker;
229
+ if (!this._terminal || !marker) {
230
+ return;
231
+ }
232
+ const line = toLineIndex(marker);
233
+ const promptRowCount = command.getPromptRowCount();
234
+ const commandRowCount = command.getCommandRowCount();
235
+ this._scrollToMarker(line - (promptRowCount - 1), position, line + (commandRowCount - 1));
236
+ }
237
+ revealRange(range) {
238
+ this._scrollToMarker(range.start.y - 1, ScrollPosition.Middle, range.end.y - 1, {
239
+ bufferRange: range,
240
+ forceScroll: !!this._configurationService.getValue(TerminalContribSettingId.StickyScrollEnabled)
241
+ });
242
+ }
243
+ showCommandGuide(command) {
244
+ if (!this._terminal) {
245
+ return;
246
+ }
247
+ if (!command) {
248
+ this._commandGuideDecorations.clear();
249
+ this._activeCommandGuide = undefined;
250
+ return;
251
+ }
252
+ if (this._activeCommandGuide === command) {
253
+ return;
254
+ }
255
+ if (command.marker) {
256
+ this._activeCommandGuide = command;
257
+ const store = this._commandGuideDecorations.value = ( new DisposableStore());
258
+ if (!command.executedMarker || !command.endMarker) {
259
+ return;
260
+ }
261
+ const startLine = command.marker.line - (command.getPromptRowCount() - 1);
262
+ const decorationCount = toLineIndex(command.endMarker) - startLine;
263
+ if (decorationCount > 200) {
264
+ return;
265
+ }
266
+ for (let i = 0; i < decorationCount; i++) {
267
+ const decoration = this._terminal.registerDecoration({
268
+ marker: this._createMarkerForOffset(startLine, i)
269
+ });
270
+ if (decoration) {
271
+ store.add(decoration);
272
+ let renderedElement;
273
+ store.add(decoration.onRender(element => {
274
+ if (!renderedElement) {
275
+ renderedElement = element;
276
+ element.classList.add('terminal-command-guide');
277
+ if (i === 0) {
278
+ element.classList.add('top');
279
+ }
280
+ if (i === decorationCount - 1) {
281
+ element.classList.add('bottom');
282
+ }
283
+ }
284
+ if (this._terminal?.element) {
285
+ element.style.marginLeft = `-${getWindow(this._terminal.element).getComputedStyle(this._terminal.element).paddingLeft}`;
286
+ }
287
+ }));
288
+ }
289
+ }
290
+ }
291
+ }
292
+ saveScrollState() {
293
+ this._scrollState = { viewportY: this._terminal?.buffer.active.viewportY ?? 0 };
294
+ }
295
+ restoreScrollState() {
296
+ if (this._scrollState && this._terminal) {
297
+ this._terminal.scrollToLine(this._scrollState.viewportY);
298
+ this._scrollState = undefined;
299
+ }
300
+ }
301
+ _highlightBufferRange(range) {
302
+ if (!this._terminal) {
303
+ return;
304
+ }
305
+ this._resetNavigationDecorations();
306
+ const startLine = range.start.y;
307
+ const decorationCount = range.end.y - range.start.y + 1;
308
+ for (let i = 0; i < decorationCount; i++) {
309
+ const decoration = this._terminal.registerDecoration({
310
+ marker: this._createMarkerForOffset(startLine - 1, i),
311
+ x: range.start.x - 1,
312
+ width: (range.end.x - 1) - (range.start.x - 1) + 1,
313
+ overviewRulerOptions: undefined
314
+ });
315
+ if (decoration) {
316
+ this._navigationDecorations?.push(decoration);
317
+ let renderedElement;
318
+ decoration.onRender(element => {
319
+ if (!renderedElement) {
320
+ renderedElement = element;
321
+ element.classList.add('terminal-range-highlight');
322
+ }
323
+ });
324
+ decoration.onDispose(() => { this._navigationDecorations = this._navigationDecorations?.filter(d => d !== decoration); });
325
+ }
326
+ }
327
+ }
328
+ registerTemporaryDecoration(marker, endMarker, showOutline) {
329
+ if (!this._terminal) {
330
+ return;
331
+ }
332
+ this._resetNavigationDecorations();
333
+ const color = this._themeService.getColorTheme().getColor(TERMINAL_OVERVIEW_RULER_CURSOR_FOREGROUND_COLOR);
334
+ const startLine = toLineIndex(marker);
335
+ const decorationCount = endMarker ? toLineIndex(endMarker) - startLine + 1 : 1;
336
+ for (let i = 0; i < decorationCount; i++) {
337
+ const decoration = this._terminal.registerDecoration({
338
+ marker: this._createMarkerForOffset(marker, i),
339
+ width: this._terminal.cols,
340
+ overviewRulerOptions: i === 0 ? {
341
+ color: color?.toString() || '#a0a0a0cc'
342
+ } : undefined
343
+ });
344
+ if (decoration) {
345
+ this._navigationDecorations?.push(decoration);
346
+ let renderedElement;
347
+ decoration.onRender(element => {
348
+ if (!renderedElement) {
349
+ renderedElement = element;
350
+ element.classList.add('terminal-scroll-highlight');
351
+ if (showOutline) {
352
+ element.classList.add('terminal-scroll-highlight-outline');
353
+ }
354
+ if (i === 0) {
355
+ element.classList.add('top');
356
+ }
357
+ if (i === decorationCount - 1) {
358
+ element.classList.add('bottom');
359
+ }
360
+ }
361
+ else {
362
+ element.classList.add('terminal-scroll-highlight');
363
+ }
364
+ if (this._terminal?.element) {
365
+ element.style.marginLeft = `-${getWindow(this._terminal.element).getComputedStyle(this._terminal.element).paddingLeft}`;
366
+ }
367
+ });
368
+ decoration.onDispose(() => { this._navigationDecorations = this._navigationDecorations?.filter(d => d !== decoration); });
369
+ if (showOutline) {
370
+ timeout(350).then(() => {
371
+ if (renderedElement) {
372
+ renderedElement.classList.remove('terminal-scroll-highlight-outline');
373
+ }
374
+ });
375
+ }
376
+ }
377
+ }
378
+ }
379
+ scrollToLine(line, position) {
380
+ this._terminal?.scrollToLine(this.getTargetScrollLine(line, position));
381
+ }
382
+ getTargetScrollLine(line, position) {
383
+ if (this._terminal && position === ScrollPosition.Middle) {
384
+ return Math.max(line - Math.floor(this._terminal.rows / 4), 0);
385
+ }
386
+ return line;
387
+ }
388
+ _isMarkerInViewport(terminal, marker) {
389
+ const viewportY = terminal.buffer.active.viewportY;
390
+ const line = toLineIndex(marker);
391
+ return line >= viewportY && line < viewportY + terminal.rows;
392
+ }
393
+ scrollToClosestMarker(startMarkerId, endMarkerId, highlight) {
394
+ const detectionCapability = this._capabilities.get(TerminalCapability.BufferMarkDetection);
395
+ if (!detectionCapability) {
396
+ return;
397
+ }
398
+ const startMarker = detectionCapability.getMark(startMarkerId);
399
+ if (!startMarker) {
400
+ return;
401
+ }
402
+ const endMarker = endMarkerId ? detectionCapability.getMark(endMarkerId) : startMarker;
403
+ this._scrollToMarker(startMarker, ScrollPosition.Top, endMarker, { hideDecoration: !highlight });
404
+ }
405
+ selectToPreviousMark() {
406
+ if (!this._terminal) {
407
+ return;
408
+ }
409
+ if (this._selectionStart === null) {
410
+ this._selectionStart = this._currentMarker;
411
+ }
412
+ if (( this._capabilities.has(TerminalCapability.CommandDetection))) {
413
+ this.scrollToPreviousMark(ScrollPosition.Middle, true, true);
414
+ }
415
+ else {
416
+ this.scrollToPreviousMark(ScrollPosition.Middle, true, false);
417
+ }
418
+ selectLines(this._terminal, this._currentMarker, this._selectionStart);
419
+ }
420
+ selectToNextMark() {
421
+ if (!this._terminal) {
422
+ return;
423
+ }
424
+ if (this._selectionStart === null) {
425
+ this._selectionStart = this._currentMarker;
426
+ }
427
+ if (( this._capabilities.has(TerminalCapability.CommandDetection))) {
428
+ this.scrollToNextMark(ScrollPosition.Middle, true, true);
429
+ }
430
+ else {
431
+ this.scrollToNextMark(ScrollPosition.Middle, true, false);
432
+ }
433
+ selectLines(this._terminal, this._currentMarker, this._selectionStart);
434
+ }
435
+ selectToPreviousLine() {
436
+ if (!this._terminal) {
437
+ return;
438
+ }
439
+ if (this._selectionStart === null) {
440
+ this._selectionStart = this._currentMarker;
441
+ }
442
+ this.scrollToPreviousLine(this._terminal, ScrollPosition.Middle, true);
443
+ selectLines(this._terminal, this._currentMarker, this._selectionStart);
444
+ }
445
+ selectToNextLine() {
446
+ if (!this._terminal) {
447
+ return;
448
+ }
449
+ if (this._selectionStart === null) {
450
+ this._selectionStart = this._currentMarker;
451
+ }
452
+ this.scrollToNextLine(this._terminal, ScrollPosition.Middle, true);
453
+ selectLines(this._terminal, this._currentMarker, this._selectionStart);
454
+ }
455
+ scrollToPreviousLine(xterm, scrollPosition = ScrollPosition.Middle, retainSelection = false) {
456
+ if (!retainSelection) {
457
+ this._selectionStart = null;
458
+ }
459
+ if (this._currentMarker === Boundary.Top) {
460
+ xterm.scrollToTop();
461
+ return;
462
+ }
463
+ if (this._currentMarker === Boundary.Bottom) {
464
+ this._currentMarker = this._registerMarkerOrThrow(xterm, this._getOffset(xterm) - 1);
465
+ }
466
+ else {
467
+ const offset = this._getOffset(xterm);
468
+ if (this._isDisposable) {
469
+ this._currentMarker.dispose();
470
+ }
471
+ this._currentMarker = this._registerMarkerOrThrow(xterm, offset - 1);
472
+ }
473
+ this._isDisposable = true;
474
+ this._scrollToMarker(this._currentMarker, scrollPosition);
475
+ }
476
+ scrollToNextLine(xterm, scrollPosition = ScrollPosition.Middle, retainSelection = false) {
477
+ if (!retainSelection) {
478
+ this._selectionStart = null;
479
+ }
480
+ if (this._currentMarker === Boundary.Bottom) {
481
+ xterm.scrollToBottom();
482
+ return;
483
+ }
484
+ if (this._currentMarker === Boundary.Top) {
485
+ this._currentMarker = this._registerMarkerOrThrow(xterm, this._getOffset(xterm) + 1);
486
+ }
487
+ else {
488
+ const offset = this._getOffset(xterm);
489
+ if (this._isDisposable) {
490
+ this._currentMarker.dispose();
491
+ }
492
+ this._currentMarker = this._registerMarkerOrThrow(xterm, offset + 1);
493
+ }
494
+ this._isDisposable = true;
495
+ this._scrollToMarker(this._currentMarker, scrollPosition);
496
+ }
497
+ _registerMarkerOrThrow(xterm, cursorYOffset) {
498
+ const marker = xterm.registerMarker(cursorYOffset);
499
+ if (!marker) {
500
+ throw ( new Error(`Could not create marker for ${cursorYOffset}`));
501
+ }
502
+ return marker;
503
+ }
504
+ _getOffset(xterm) {
505
+ if (this._currentMarker === Boundary.Bottom) {
506
+ return 0;
507
+ }
508
+ else if (this._currentMarker === Boundary.Top) {
509
+ return 0 - (xterm.buffer.active.baseY + xterm.buffer.active.cursorY);
510
+ }
511
+ else {
512
+ let offset = getLine(xterm, this._currentMarker);
513
+ offset -= xterm.buffer.active.baseY + xterm.buffer.active.cursorY;
514
+ return offset;
515
+ }
516
+ }
517
+ _findPreviousMarker(skipEmptyCommands = false) {
518
+ if (this._currentMarker === Boundary.Top) {
519
+ return 0;
520
+ }
521
+ else if (this._currentMarker === Boundary.Bottom) {
522
+ return this._getMarkers(skipEmptyCommands).length - 1;
523
+ }
524
+ let i;
525
+ for (i = this._getMarkers(skipEmptyCommands).length - 1; i >= 0; i--) {
526
+ if (this._getMarkers(skipEmptyCommands)[i].line < this._currentMarker.line) {
527
+ return i;
528
+ }
529
+ }
530
+ return -1;
531
+ }
532
+ _findNextMarker(skipEmptyCommands = false) {
533
+ if (this._currentMarker === Boundary.Top) {
534
+ return 0;
535
+ }
536
+ else if (this._currentMarker === Boundary.Bottom) {
537
+ return this._getMarkers(skipEmptyCommands).length - 1;
538
+ }
539
+ let i;
540
+ for (i = 0; i < this._getMarkers(skipEmptyCommands).length; i++) {
541
+ if (this._getMarkers(skipEmptyCommands)[i].line > this._currentMarker.line) {
542
+ return i;
543
+ }
544
+ }
545
+ return this._getMarkers(skipEmptyCommands).length;
546
+ }
547
+ };
548
+ MarkNavigationAddon = ( __decorate([
549
+ ( __param(1, IConfigurationService)),
550
+ ( __param(2, IThemeService))
551
+ ], MarkNavigationAddon));
552
+ function getLine(xterm, marker) {
553
+ if (marker === Boundary.Bottom) {
554
+ return xterm.buffer.active.baseY + xterm.rows - 1;
555
+ }
556
+ if (marker === Boundary.Top) {
557
+ return 0;
558
+ }
559
+ return marker.line;
560
+ }
561
+ function selectLines(xterm, start, end) {
562
+ if (end === null) {
563
+ end = Boundary.Bottom;
564
+ }
565
+ let startLine = getLine(xterm, start);
566
+ let endLine = getLine(xterm, end);
567
+ if (startLine > endLine) {
568
+ const temp = startLine;
569
+ startLine = endLine;
570
+ endLine = temp;
571
+ }
572
+ endLine -= 1;
573
+ xterm.selectLines(startLine, endLine);
574
+ }
575
+ function isMarker(value) {
576
+ return typeof value !== 'number';
577
+ }
578
+ function toLineIndex(line) {
579
+ return isMarker(line) ? line.line : line;
580
+ }
581
+
582
+ export { MarkNavigationAddon, ScrollPosition, getLine, selectLines };
@@ -0,0 +1,25 @@
1
+ import type { ClipboardAddon as ClipboardAddonType } from "@xterm/addon-clipboard";
2
+ import type { ImageAddon as ImageAddonType } from "@xterm/addon-image";
3
+ import type { LigaturesAddon as LigaturesAddonType } from "@xterm/addon-ligatures";
4
+ import type { ProgressAddon as ProgressAddonType } from "@xterm/addon-progress";
5
+ import type { SearchAddon as SearchAddonType } from "@xterm/addon-search";
6
+ import type { SerializeAddon as SerializeAddonType } from "@xterm/addon-serialize";
7
+ import type { Unicode11Addon as Unicode11AddonType } from "@xterm/addon-unicode11";
8
+ import type { WebglAddon as WebglAddonType } from "@xterm/addon-webgl";
9
+ export interface IXtermAddonNameToCtor {
10
+ clipboard: typeof ClipboardAddonType;
11
+ image: typeof ImageAddonType;
12
+ ligatures: typeof LigaturesAddonType;
13
+ progress: typeof ProgressAddonType;
14
+ search: typeof SearchAddonType;
15
+ serialize: typeof SerializeAddonType;
16
+ unicode11: typeof Unicode11AddonType;
17
+ webgl: typeof WebglAddonType;
18
+ }
19
+ /**
20
+ * Exposes a simple interface to consumers, encapsulating the messy import xterm
21
+ * addon import and caching logic.
22
+ */
23
+ export declare class XtermAddonImporter {
24
+ importAddon<T extends keyof IXtermAddonNameToCtor>(name: T): Promise<IXtermAddonNameToCtor[T]>;
25
+ }
@@ -0,0 +1,43 @@
1
+
2
+
3
+ const importedAddons = ( new Map());
4
+ class XtermAddonImporter {
5
+ async importAddon(name) {
6
+ let addon = importedAddons.get(name);
7
+ if (!addon) {
8
+ switch (name) {
9
+ case 'clipboard':
10
+ addon = (await import('@xterm/addon-clipboard').then(module => module.default ?? module)).ClipboardAddon;
11
+ break;
12
+ case 'image':
13
+ addon = (await import('@xterm/addon-image').then(module => module.default ?? module)).ImageAddon;
14
+ break;
15
+ case 'ligatures':
16
+ addon = (await import('@xterm/addon-ligatures').then(module => module.default ?? module)).LigaturesAddon;
17
+ break;
18
+ case 'progress':
19
+ addon = (await import('@xterm/addon-progress').then(module => module.default ?? module)).ProgressAddon;
20
+ break;
21
+ case 'search':
22
+ addon = (await import('@xterm/addon-search').then(module => module.default ?? module)).SearchAddon;
23
+ break;
24
+ case 'serialize':
25
+ addon = (await import('@xterm/addon-serialize').then(module => module.default ?? module)).SerializeAddon;
26
+ break;
27
+ case 'unicode11':
28
+ addon = (await import('@xterm/addon-unicode11').then(module => module.default ?? module)).Unicode11Addon;
29
+ break;
30
+ case 'webgl':
31
+ addon = (await import('@xterm/addon-webgl').then(module => module.default ?? module)).WebglAddon;
32
+ break;
33
+ }
34
+ if (!addon) {
35
+ throw ( new Error(`Could not load addon ${name}`));
36
+ }
37
+ importedAddons.set(name, addon);
38
+ }
39
+ return addon;
40
+ }
41
+ }
42
+
43
+ export { XtermAddonImporter };