cleanup BufferLine.ts

This commit is contained in:
Jörg Breitbart
2018-08-30 17:58:37 +02:00
parent 71f5965f8e
commit a1421b151e
+1 -17
View File
@@ -7,22 +7,10 @@ import { NULL_CELL_CODE, NULL_CELL_WIDTH, NULL_CELL_CHAR } from './Buffer';
/**
* Class representing a terminal line.
* Currently the class is a thin proxy to `CharData[]`.
* Once the storages are in place it will proxy access to
* typed array based line data.
* TODO:
* - move Buffer.translateBufferLineToString here?
* - next steps towards typed array:
* - create ITerminalLine interface w'o length methods
* - resize method
* - replace all external push/pop/splice accesses
* - fixed length
* - remove push/pop/splice
* - implement typed array alternative once string is removed from CharData
*/
export class BufferLine implements IBufferLine {
static defaultCell: CharData = [0, NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE];
static blankLine(cols: number, attr: number, isWrapped?: boolean): BufferLine {
static blankLine(cols: number, attr: number, isWrapped?: boolean): IBufferLine {
const ch: CharData = [attr, NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE];
return new BufferLine(cols, ch, isWrapped);
}
@@ -52,23 +40,19 @@ export class BufferLine implements IBufferLine {
public set(index: number, data: CharData): void {
this._data[index] = data;
// TODO: unref old, ref new
}
// to be removed for typed array
public pop(): CharData | undefined {
const data = this._data.pop();
this.length = this._data.length;
return data;
}
// to be removed for typed array
public push(data: CharData): void {
this._data.push(data);
this.length = this._data.length;
}
// to be removed for typed array
public splice(start: number, deleteCount: number, ...items: CharData[]): CharData[] {
const removed = this._data.splice(start, deleteCount, ...items);
this.length = this._data.length;