better integration and experimentalPushRecycling option
This commit is contained in:
+24
-10
@@ -106,7 +106,8 @@ const DEFAULT_OPTIONS: ITerminalOptions = {
|
|||||||
theme: null,
|
theme: null,
|
||||||
rightClickSelectsWord: Browser.isMac,
|
rightClickSelectsWord: Browser.isMac,
|
||||||
rendererType: 'canvas',
|
rendererType: 'canvas',
|
||||||
experimentalBufferLineImpl: 'JsArray'
|
experimentalBufferLineImpl: 'JsArray',
|
||||||
|
experimentalPushRecycling: false
|
||||||
};
|
};
|
||||||
|
|
||||||
export class Terminal extends EventEmitter implements ITerminal, IDisposable, IInputHandlingTerminal {
|
export class Terminal extends EventEmitter implements ITerminal, IDisposable, IInputHandlingTerminal {
|
||||||
@@ -208,6 +209,9 @@ export class Terminal extends EventEmitter implements ITerminal, IDisposable, II
|
|||||||
private _screenDprMonitor: ScreenDprMonitor;
|
private _screenDprMonitor: ScreenDprMonitor;
|
||||||
private _theme: ITheme;
|
private _theme: ITheme;
|
||||||
|
|
||||||
|
// bufferline to clone/copy from for new blank lines
|
||||||
|
private _blankLine: IBufferLine = null;
|
||||||
|
|
||||||
public cols: number;
|
public cols: number;
|
||||||
public rows: number;
|
public rows: number;
|
||||||
|
|
||||||
@@ -496,6 +500,7 @@ export class Terminal extends EventEmitter implements ITerminal, IDisposable, II
|
|||||||
case 'experimentalBufferLineImpl':
|
case 'experimentalBufferLineImpl':
|
||||||
this.buffers.normal.setBufferLineFactory(value);
|
this.buffers.normal.setBufferLineFactory(value);
|
||||||
this.buffers.alt.setBufferLineFactory(value);
|
this.buffers.alt.setBufferLineFactory(value);
|
||||||
|
this._blankLine = null;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// Inform renderer of changes
|
// Inform renderer of changes
|
||||||
@@ -1174,13 +1179,18 @@ export class Terminal extends EventEmitter implements ITerminal, IDisposable, II
|
|||||||
* @param isWrapped Whether the new line is wrapped from the previous line.
|
* @param isWrapped Whether the new line is wrapped from the previous line.
|
||||||
*/
|
*/
|
||||||
public scroll(isWrapped?: boolean): void {
|
public scroll(isWrapped?: boolean): void {
|
||||||
// TODO: make blank a member
|
let newLine: IBufferLine;
|
||||||
let blank: IBufferLine = (this as any)._blank;
|
const useRecycling = this.options.experimentalPushRecycling;
|
||||||
if (!blank || blank.length !== this.cols) {
|
if (useRecycling) {
|
||||||
blank = this.buffer.getBlankLine(DEFAULT_ATTR, isWrapped);
|
newLine = this._blankLine;
|
||||||
(this as any)._blank = blank;
|
if (!newLine || newLine.length !== this.cols) {
|
||||||
|
newLine = this.buffer.getBlankLine(DEFAULT_ATTR, isWrapped);
|
||||||
|
this._blankLine = newLine;
|
||||||
|
}
|
||||||
|
newLine.isWrapped = !!(isWrapped);
|
||||||
|
} else {
|
||||||
|
newLine = this.buffer.getBlankLine(DEFAULT_ATTR, isWrapped);
|
||||||
}
|
}
|
||||||
blank.isWrapped = !!(isWrapped);
|
|
||||||
|
|
||||||
const topRow = this.buffer.ybase + this.buffer.scrollTop;
|
const topRow = this.buffer.ybase + this.buffer.scrollTop;
|
||||||
const bottomRow = this.buffer.ybase + this.buffer.scrollBottom;
|
const bottomRow = this.buffer.ybase + this.buffer.scrollBottom;
|
||||||
@@ -1191,9 +1201,13 @@ export class Terminal extends EventEmitter implements ITerminal, IDisposable, II
|
|||||||
|
|
||||||
// Insert the line using the fastest method
|
// Insert the line using the fastest method
|
||||||
if (bottomRow === this.buffer.lines.length - 1) {
|
if (bottomRow === this.buffer.lines.length - 1) {
|
||||||
(this.buffer.lines as any).pushRecycling((line: IBufferLine | undefined) => (line) ? line.copyFrom(blank) : blank.clone());
|
if (useRecycling) {
|
||||||
|
this.buffer.lines.pushRecycling((item) => (item) ? item.copyFrom(newLine) : newLine.clone());
|
||||||
|
} else {
|
||||||
|
this.buffer.lines.push(newLine);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.buffer.lines.splice(bottomRow + 1, 0, blank.clone());
|
this.buffer.lines.splice(bottomRow + 1, 0, (useRecycling) ? newLine.clone() : newLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only adjust ybase and ydisp when the buffer is not trimmed
|
// Only adjust ybase and ydisp when the buffer is not trimmed
|
||||||
@@ -1215,7 +1229,7 @@ export class Terminal extends EventEmitter implements ITerminal, IDisposable, II
|
|||||||
// scrollback, instead we can just shift them in-place.
|
// scrollback, instead we can just shift them in-place.
|
||||||
const scrollRegionHeight = bottomRow - topRow + 1/*as it's zero-based*/;
|
const scrollRegionHeight = bottomRow - topRow + 1/*as it's zero-based*/;
|
||||||
this.buffer.lines.shiftElements(topRow + 1, scrollRegionHeight - 1, -1);
|
this.buffer.lines.shiftElements(topRow + 1, scrollRegionHeight - 1, -1);
|
||||||
this.buffer.lines.set(bottomRow, blank.clone());
|
this.buffer.lines.set(bottomRow, (useRecycling) ? newLine.clone() : newLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move the viewport to the bottom of the buffer unless the user is
|
// Move the viewport to the bottom of the buffer unless the user is
|
||||||
|
|||||||
+1
-1
@@ -522,7 +522,7 @@ export interface IBufferLine {
|
|||||||
replaceCells(start: number, end: number, fill: CharData): void;
|
replaceCells(start: number, end: number, fill: CharData): void;
|
||||||
resize(cols: number, fill: CharData, shrink?: boolean): void;
|
resize(cols: number, fill: CharData, shrink?: boolean): void;
|
||||||
fill(fillCharData: CharData): void;
|
fill(fillCharData: CharData): void;
|
||||||
copyFrom(line: IBufferLine): void;
|
copyFrom(line: IBufferLine): IBufferLine;
|
||||||
clone(): IBufferLine;
|
clone(): IBufferLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ export class CircularList<T> extends EventEmitter implements ICircularList<T> {
|
|||||||
* The callback gets the value at the current position to be overwritten.
|
* The callback gets the value at the current position to be overwritten.
|
||||||
* Return the new value from the callback.
|
* Return the new value from the callback.
|
||||||
*/
|
*/
|
||||||
public pushRecycling(callback: (el: T | undefined) => T): void {
|
public pushRecycling(callback: (item: T | undefined) => T): void {
|
||||||
this._array[this._getCyclicIndex(this._length)] = callback(this._array[this._getCyclicIndex(this._length)]);
|
this._array[this._getCyclicIndex(this._length)] = callback(this._array[this._getCyclicIndex(this._length)]);
|
||||||
if (this._length === this._maxLength) {
|
if (this._length === this._maxLength) {
|
||||||
this._startIndex++;
|
this._startIndex++;
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ export interface ICircularList<T> extends IEventEmitter {
|
|||||||
get(index: number): T | undefined;
|
get(index: number): T | undefined;
|
||||||
set(index: number, value: T): void;
|
set(index: number, value: T): void;
|
||||||
push(value: T): void;
|
push(value: T): void;
|
||||||
|
pushRecycling(callback: (item: T | undefined) => T): void;
|
||||||
pop(): T | undefined;
|
pop(): T | undefined;
|
||||||
splice(start: number, deleteCount: number, ...items: T[]): void;
|
splice(start: number, deleteCount: number, ...items: T[]): void;
|
||||||
trimStart(count: number): void;
|
trimStart(count: number): void;
|
||||||
|
|||||||
Vendored
+2
@@ -112,6 +112,8 @@ declare module 'xterm' {
|
|||||||
*/
|
*/
|
||||||
experimentalBufferLineImpl?: 'JsArray' | 'TypedArray';
|
experimentalBufferLineImpl?: 'JsArray' | 'TypedArray';
|
||||||
|
|
||||||
|
experimentalPushRecycling?: boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The font size used to render text.
|
* The font size used to render text.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user