Skip to content

Commit

Permalink
Revert "Remove getNullCell"
Browse files Browse the repository at this point in the history
This reverts commit 0b6a5b7.
  • Loading branch information
Tyriar committed Feb 4, 2020
1 parent 9b9cb5c commit 9c8deb1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 17 deletions.
20 changes: 3 additions & 17 deletions addons/xterm-addon-serialize/src/SerializeAddon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ abstract class BaseSerializeHandler {
constructor(private _buffer: IBuffer) { }

serialize(startRow: number, endRow: number): string {
const { cell1, cell2 } = this._getWorkCells();
// we need two of them to flip between old and new cell
const cell1 = this._buffer.getNullCell();
const cell2 = this._buffer.getNullCell();
let oldCell = cell1;

this._beforeSerialize(endRow - startRow);
Expand All @@ -42,22 +44,6 @@ abstract class BaseSerializeHandler {
return this._serializeString();
}

private _getWorkCells(): { cell1: IBufferCell, cell2: IBufferCell } {
const line = this._buffer.getLine(0);
if (!line) {
throw new Error('Could not fetch first line for serialization');
}
const cell1 = line.getCell(0);
if (!cell1) {
throw new Error('Could not fetch first cell for serialization');
}
const cell2 = line.getCell(0);
if (!cell2) {
throw new Error('Could not fetch first cell for serialization');
}
return { cell1, cell2 };
}

protected _nextCell(cell: IBufferCell, oldCell: IBufferCell, row: number, col: number): void { }
protected _rowEnd(row: number): void { }
protected _beforeSerialize(rows: number): void { }
Expand Down
1 change: 1 addition & 0 deletions src/public/Terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ class BufferApiView implements IBufferApi {
}
return new BufferLineApiView(line);
}
public getNullCell(): IBufferCellApi { return new CellData(); }
}

class BufferLineApiView implements IBufferLineApi {
Expand Down
7 changes: 7 additions & 0 deletions typings/xterm.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1117,6 +1117,13 @@ declare module 'xterm' {
* @param y The line index to get.
*/
getLine(y: number): IBufferLine | undefined;

/**
* Creates an empty cell object suitable as a cell reference in
* `line.getCell(x, cell)`. Use this to avoid costly recreation of
* cell objects when dealing with tons of cells.
*/
getNullCell(): IBufferCell;
}

/**
Expand Down

0 comments on commit 9c8deb1

Please sign in to comment.