@xterm/xterm 6.1.0-beta.190 → 6.1.0-beta.192
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/xterm.js +1 -1
- package/lib/xterm.js.map +1 -1
- package/lib/xterm.mjs +7 -7
- package/lib/xterm.mjs.map +3 -3
- package/package.json +2 -2
- package/src/browser/renderer/dom/DomRenderer.ts +77 -33
- package/src/common/Version.ts +1 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xterm/xterm",
|
|
3
3
|
"description": "Full xterm terminal, in your browser",
|
|
4
|
-
"version": "6.1.0-beta.
|
|
4
|
+
"version": "6.1.0-beta.192",
|
|
5
5
|
"main": "lib/xterm.js",
|
|
6
6
|
"module": "lib/xterm.mjs",
|
|
7
7
|
"style": "css/xterm.css",
|
|
@@ -119,5 +119,5 @@
|
|
|
119
119
|
"ws": "^8.2.3",
|
|
120
120
|
"xterm-benchmark": "^0.3.1"
|
|
121
121
|
},
|
|
122
|
-
"commit": "
|
|
122
|
+
"commit": "fe0952bb835155f17cbc8752bdf63ecde21d7c53"
|
|
123
123
|
}
|
|
@@ -45,6 +45,9 @@ export class DomRenderer extends Disposable implements IRenderer {
|
|
|
45
45
|
private _selectionContainer: HTMLElement;
|
|
46
46
|
private _widthCache: WidthCache;
|
|
47
47
|
private _selectionRenderModel: ISelectionRenderModel = createSelectionRenderModel();
|
|
48
|
+
private _lastSelectionStart: [number, number] | undefined;
|
|
49
|
+
private _lastSelectionEnd: [number, number] | undefined;
|
|
50
|
+
private _lastSelectionColumnMode: boolean = false;
|
|
48
51
|
private _cursorBlinkStateManager: CursorBlinkStateManager;
|
|
49
52
|
private _textBlinkStateManager: TextBlinkStateManager;
|
|
50
53
|
private _rowHasBlinkingCells: boolean[] = [];
|
|
@@ -184,6 +187,9 @@ export class DomRenderer extends Disposable implements IRenderer {
|
|
|
184
187
|
// refresh() being called during the mousedown handler to start a selection.
|
|
185
188
|
` pointer-events: none;` +
|
|
186
189
|
` color: ${colors.foreground.css};` +
|
|
190
|
+
`}`;
|
|
191
|
+
styles +=
|
|
192
|
+
`${this._terminalSelector} .${ROW_CONTAINER_CLASS}, ${this._terminalSelector} .${ROW_CONTAINER_CLASS} span {` +
|
|
187
193
|
` font-family: ${this._optionsService.rawOptions.fontFamily};` +
|
|
188
194
|
` font-size: ${this._optionsService.rawOptions.fontSize}px;` +
|
|
189
195
|
` font-kerning: none;` +
|
|
@@ -371,51 +377,89 @@ export class DomRenderer extends Disposable implements IRenderer {
|
|
|
371
377
|
}
|
|
372
378
|
|
|
373
379
|
public handleSelectionChanged(start: [number, number] | undefined, end: [number, number] | undefined, columnSelectMode: boolean): void {
|
|
380
|
+
const rows = this._bufferService.rows;
|
|
381
|
+
|
|
374
382
|
// Remove all selections
|
|
375
383
|
this._selectionContainer.replaceChildren();
|
|
376
384
|
this._rowFactory.handleSelectionChanged(start, end, columnSelectMode);
|
|
377
|
-
this.renderRows(0, this._bufferService.rows - 1);
|
|
378
385
|
|
|
379
|
-
//
|
|
386
|
+
// Determine old selection viewport band
|
|
387
|
+
let oldViewportStart = 0;
|
|
388
|
+
let oldViewportEnd = -1;
|
|
389
|
+
if (this._lastSelectionStart && this._lastSelectionEnd) {
|
|
390
|
+
this._selectionRenderModel.update(this._terminal, this._lastSelectionStart, this._lastSelectionEnd, this._lastSelectionColumnMode);
|
|
391
|
+
if (this._selectionRenderModel.hasSelection) {
|
|
392
|
+
oldViewportStart = this._selectionRenderModel.viewportCappedStartRow;
|
|
393
|
+
oldViewportEnd = this._selectionRenderModel.viewportCappedEndRow;
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
// Determine new selection viewport band and create overlays
|
|
398
|
+
let newViewportStart = 0;
|
|
399
|
+
let newViewportEnd = -1;
|
|
380
400
|
if (!start || !end) {
|
|
381
401
|
return;
|
|
382
402
|
}
|
|
383
|
-
|
|
384
403
|
this._selectionRenderModel.update(this._terminal, start, end, columnSelectMode);
|
|
385
|
-
if (
|
|
386
|
-
|
|
404
|
+
if (this._selectionRenderModel.hasSelection) {
|
|
405
|
+
const viewportStartRow = this._selectionRenderModel.viewportStartRow;
|
|
406
|
+
const viewportEndRow = this._selectionRenderModel.viewportEndRow;
|
|
407
|
+
const viewportCappedStartRow = this._selectionRenderModel.viewportCappedStartRow;
|
|
408
|
+
const viewportCappedEndRow = this._selectionRenderModel.viewportCappedEndRow;
|
|
409
|
+
|
|
410
|
+
newViewportStart = viewportCappedStartRow;
|
|
411
|
+
newViewportEnd = viewportCappedEndRow;
|
|
412
|
+
|
|
413
|
+
// Create the selections
|
|
414
|
+
const documentFragment = this._document.createDocumentFragment();
|
|
415
|
+
|
|
416
|
+
if (columnSelectMode) {
|
|
417
|
+
const isXFlipped = start[0] > end[0];
|
|
418
|
+
documentFragment.appendChild(
|
|
419
|
+
this._createSelectionElement(viewportCappedStartRow, isXFlipped ? end[0] : start[0], isXFlipped ? start[0] : end[0], viewportCappedEndRow - viewportCappedStartRow + 1)
|
|
420
|
+
);
|
|
421
|
+
} else {
|
|
422
|
+
// Draw first row
|
|
423
|
+
const startCol = viewportStartRow === viewportCappedStartRow ? start[0] : 0;
|
|
424
|
+
const endCol = viewportCappedStartRow === viewportEndRow ? end[0] : this._bufferService.cols;
|
|
425
|
+
documentFragment.appendChild(this._createSelectionElement(viewportCappedStartRow, startCol, endCol));
|
|
426
|
+
// Draw middle rows
|
|
427
|
+
const middleRowsCount = viewportCappedEndRow - viewportCappedStartRow - 1;
|
|
428
|
+
documentFragment.appendChild(this._createSelectionElement(viewportCappedStartRow + 1, 0, this._bufferService.cols, middleRowsCount));
|
|
429
|
+
// Draw final row
|
|
430
|
+
if (viewportCappedStartRow !== viewportCappedEndRow) {
|
|
431
|
+
// Only draw viewportEndRow if it's not the same as viewporttartRow
|
|
432
|
+
const finalEndCol = viewportEndRow === viewportCappedEndRow ? end[0] : this._bufferService.cols;
|
|
433
|
+
documentFragment.appendChild(this._createSelectionElement(viewportCappedEndRow, 0, finalEndCol));
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
this._selectionContainer.appendChild(documentFragment);
|
|
387
437
|
}
|
|
388
438
|
|
|
389
|
-
//
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
const
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
// Draw first row
|
|
405
|
-
const startCol = viewportStartRow === viewportCappedStartRow ? start[0] : 0;
|
|
406
|
-
const endCol = viewportCappedStartRow === viewportEndRow ? end[0] : this._bufferService.cols;
|
|
407
|
-
documentFragment.appendChild(this._createSelectionElement(viewportCappedStartRow, startCol, endCol));
|
|
408
|
-
// Draw middle rows
|
|
409
|
-
const middleRowsCount = viewportCappedEndRow - viewportCappedStartRow - 1;
|
|
410
|
-
documentFragment.appendChild(this._createSelectionElement(viewportCappedStartRow + 1, 0, this._bufferService.cols, middleRowsCount));
|
|
411
|
-
// Draw final row
|
|
412
|
-
if (viewportCappedStartRow !== viewportCappedEndRow) {
|
|
413
|
-
// Only draw viewportEndRow if it's not the same as viewporttartRow
|
|
414
|
-
const endCol = viewportEndRow === viewportCappedEndRow ? end[0] : this._bufferService.cols;
|
|
415
|
-
documentFragment.appendChild(this._createSelectionElement(viewportCappedEndRow, 0, endCol));
|
|
439
|
+
// Compute minimal row range to redraw
|
|
440
|
+
let renderStartRow = Math.min(oldViewportStart, newViewportStart);
|
|
441
|
+
let renderEndRow = Math.max(oldViewportEnd, newViewportEnd);
|
|
442
|
+
|
|
443
|
+
if (renderEndRow >= 0) {
|
|
444
|
+
// Clamp to viewport
|
|
445
|
+
renderStartRow = Math.max(renderStartRow, 0);
|
|
446
|
+
renderEndRow = Math.min(renderEndRow, rows - 1);
|
|
447
|
+
|
|
448
|
+
// Ensure cursor row is included when a selection is present
|
|
449
|
+
const buffer = this._bufferService.buffer;
|
|
450
|
+
const cursorViewportRow = buffer.y;
|
|
451
|
+
if (this._selectionRenderModel.hasSelection && cursorViewportRow >= 0 && cursorViewportRow < rows) {
|
|
452
|
+
renderStartRow = Math.min(renderStartRow, cursorViewportRow);
|
|
453
|
+
renderEndRow = Math.max(renderEndRow, cursorViewportRow);
|
|
416
454
|
}
|
|
455
|
+
|
|
456
|
+
this.renderRows(renderStartRow, renderEndRow);
|
|
417
457
|
}
|
|
418
|
-
|
|
458
|
+
|
|
459
|
+
// Update last selection state
|
|
460
|
+
this._lastSelectionStart = start;
|
|
461
|
+
this._lastSelectionEnd = end;
|
|
462
|
+
this._lastSelectionColumnMode = columnSelectMode;
|
|
419
463
|
}
|
|
420
464
|
|
|
421
465
|
/**
|
package/src/common/Version.ts
CHANGED