Merge pull request #1812 from jerch/default_buffer_to_typedarray
Deprecate JS array based terminal buffer
This commit is contained in:
+4
-4
@@ -7,7 +7,7 @@ import { CircularList } from './common/CircularList';
|
|||||||
import { CharData, ITerminal, IBuffer, IBufferLine, BufferIndex, IBufferStringIterator, IBufferStringIteratorResult, IBufferLineConstructor } from './Types';
|
import { CharData, ITerminal, IBuffer, IBufferLine, BufferIndex, IBufferStringIterator, IBufferStringIteratorResult, IBufferLineConstructor } from './Types';
|
||||||
import { EventEmitter } from './common/EventEmitter';
|
import { EventEmitter } from './common/EventEmitter';
|
||||||
import { IMarker } from 'xterm';
|
import { IMarker } from 'xterm';
|
||||||
import { BufferLine, BufferLineTypedArray } from './BufferLine';
|
import { BufferLine, BufferLineJSArray } from './BufferLine';
|
||||||
import { DEFAULT_COLOR } from './renderer/atlas/Types';
|
import { DEFAULT_COLOR } from './renderer/atlas/Types';
|
||||||
|
|
||||||
export const DEFAULT_ATTR = (0 << 18) | (DEFAULT_COLOR << 9) | (256 << 0);
|
export const DEFAULT_ATTR = (0 << 18) | (DEFAULT_COLOR << 9) | (256 << 0);
|
||||||
@@ -57,9 +57,9 @@ export class Buffer implements IBuffer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public setBufferLineFactory(type: string): void {
|
public setBufferLineFactory(type: string): void {
|
||||||
if (type === 'TypedArray') {
|
if (type === 'JsArray') {
|
||||||
if (this._bufferLineConstructor !== BufferLineTypedArray) {
|
if (this._bufferLineConstructor !== BufferLineJSArray) {
|
||||||
this._bufferLineConstructor = BufferLineTypedArray;
|
this._bufferLineConstructor = BufferLineJSArray;
|
||||||
this._recreateLines();
|
this._recreateLines();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
+8
-15
@@ -7,8 +7,10 @@ import { NULL_CELL_CODE, NULL_CELL_WIDTH, NULL_CELL_CHAR } from './Buffer';
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Class representing a terminal line.
|
* Class representing a terminal line.
|
||||||
|
*
|
||||||
|
* @deprecated to be removed with one of the next releases
|
||||||
*/
|
*/
|
||||||
export class BufferLine implements IBufferLine {
|
export class BufferLineJSArray implements IBufferLine {
|
||||||
protected _data: CharData[];
|
protected _data: CharData[];
|
||||||
public isWrapped = false;
|
public isWrapped = false;
|
||||||
public length: number;
|
public length: number;
|
||||||
@@ -94,14 +96,14 @@ export class BufferLine implements IBufferLine {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public copyFrom(line: BufferLine): void {
|
public copyFrom(line: BufferLineJSArray): void {
|
||||||
this._data = line._data.slice(0);
|
this._data = line._data.slice(0);
|
||||||
this.length = line.length;
|
this.length = line.length;
|
||||||
this.isWrapped = line.isWrapped;
|
this.isWrapped = line.isWrapped;
|
||||||
}
|
}
|
||||||
|
|
||||||
public clone(): IBufferLine {
|
public clone(): IBufferLine {
|
||||||
const newLine = new BufferLine(0);
|
const newLine = new BufferLineJSArray(0);
|
||||||
newLine.copyFrom(this);
|
newLine.copyFrom(this);
|
||||||
return newLine;
|
return newLine;
|
||||||
}
|
}
|
||||||
@@ -119,17 +121,8 @@ const enum Cell {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Typed array based bufferline implementation.
|
* Typed array based bufferline implementation.
|
||||||
* Note: Unlike the JS variant the access to the data
|
|
||||||
* via set/get is always a copy action.
|
|
||||||
* Sloppy ref style coding will not work anymore:
|
|
||||||
* line = new BufferLine(10);
|
|
||||||
* char = line.get(0); // char is a copy
|
|
||||||
* char[some_index] = 123; // will not update the line
|
|
||||||
* line.set(0, ch); // do this to update line data
|
|
||||||
* TODO:
|
|
||||||
* - provide getData/setData to directly access the data
|
|
||||||
*/
|
*/
|
||||||
export class BufferLineTypedArray implements IBufferLine {
|
export class BufferLine implements IBufferLine {
|
||||||
protected _data: Uint32Array | null = null;
|
protected _data: Uint32Array | null = null;
|
||||||
protected _combined: {[index: number]: string} = {};
|
protected _combined: {[index: number]: string} = {};
|
||||||
public length: number;
|
public length: number;
|
||||||
@@ -248,7 +241,7 @@ export class BufferLineTypedArray implements IBufferLine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** alter to a full copy of line */
|
/** alter to a full copy of line */
|
||||||
public copyFrom(line: BufferLineTypedArray): void {
|
public copyFrom(line: BufferLine): void {
|
||||||
if (this.length !== line.length) {
|
if (this.length !== line.length) {
|
||||||
this._data = new Uint32Array(line._data);
|
this._data = new Uint32Array(line._data);
|
||||||
} else {
|
} else {
|
||||||
@@ -265,7 +258,7 @@ export class BufferLineTypedArray implements IBufferLine {
|
|||||||
|
|
||||||
/** create a new clone */
|
/** create a new clone */
|
||||||
public clone(): IBufferLine {
|
public clone(): IBufferLine {
|
||||||
const newLine = new BufferLineTypedArray(0);
|
const newLine = new BufferLine(0);
|
||||||
// creation of new typed array from another is actually pretty slow :(
|
// creation of new typed array from another is actually pretty slow :(
|
||||||
// still faster than copying values one by one
|
// still faster than copying values one by one
|
||||||
newLine._data = new Uint32Array(this._data);
|
newLine._data = new Uint32Array(this._data);
|
||||||
|
|||||||
+2
-2
@@ -106,7 +106,7 @@ const DEFAULT_OPTIONS: ITerminalOptions = {
|
|||||||
theme: null,
|
theme: null,
|
||||||
rightClickSelectsWord: Browser.isMac,
|
rightClickSelectsWord: Browser.isMac,
|
||||||
rendererType: 'canvas',
|
rendererType: 'canvas',
|
||||||
experimentalBufferLineImpl: 'JsArray'
|
experimentalBufferLineImpl: 'TypedArray'
|
||||||
};
|
};
|
||||||
|
|
||||||
export class Terminal extends EventEmitter implements ITerminal, IDisposable, IInputHandlingTerminal {
|
export class Terminal extends EventEmitter implements ITerminal, IDisposable, IInputHandlingTerminal {
|
||||||
@@ -1179,7 +1179,7 @@ export class Terminal extends EventEmitter implements ITerminal, IDisposable, II
|
|||||||
*/
|
*/
|
||||||
public scroll(isWrapped: boolean = false): void {
|
public scroll(isWrapped: boolean = false): void {
|
||||||
let newLine: IBufferLine;
|
let newLine: IBufferLine;
|
||||||
const useRecycling = this.options.experimentalBufferLineImpl === 'TypedArray';
|
const useRecycling = this.options.experimentalBufferLineImpl !== 'JsArray';
|
||||||
if (useRecycling) {
|
if (useRecycling) {
|
||||||
newLine = this._blankLine;
|
newLine = this._blankLine;
|
||||||
if (!newLine || newLine.length !== this.cols || newLine.get(0)[CHAR_DATA_ATTR_INDEX] !== this.eraseAttr()) {
|
if (!newLine || newLine.length !== this.cols || newLine.get(0)[CHAR_DATA_ATTR_INDEX] !== this.eraseAttr()) {
|
||||||
|
|||||||
Vendored
+1
-1
@@ -108,7 +108,7 @@ declare module 'xterm' {
|
|||||||
* - 'TypedArray': The new experimental implementation based on TypedArrays that is expected to
|
* - 'TypedArray': The new experimental implementation based on TypedArrays that is expected to
|
||||||
* significantly boost performance and memory consumption. Use at your own risk.
|
* significantly boost performance and memory consumption. Use at your own risk.
|
||||||
*
|
*
|
||||||
* This option will be removed in the future.
|
* @deprecated This option will be removed in the future.
|
||||||
*/
|
*/
|
||||||
experimentalBufferLineImpl?: 'JsArray' | 'TypedArray';
|
experimentalBufferLineImpl?: 'JsArray' | 'TypedArray';
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user