From fe6919b52a2d9cd90a6ab59eead49d63d6af640d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Breitbart?= Date: Sat, 12 Jan 2019 15:05:52 +0100 Subject: [PATCH] change replaceCells to new interface --- src/BufferLine.test.ts | 2 +- src/BufferLine.ts | 5 ++--- src/InputHandler.ts | 9 +++++---- src/Types.ts | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/BufferLine.test.ts b/src/BufferLine.test.ts index 68384f35..c2329113 100644 --- a/src/BufferLine.test.ts +++ b/src/BufferLine.test.ts @@ -71,7 +71,7 @@ describe('BufferLine', function(): void { line.set(2, [3, 'c', 0, 'c'.charCodeAt(0)]); line.set(3, [4, 'd', 0, 'd'.charCodeAt(0)]); line.set(4, [5, 'e', 0, 'e'.charCodeAt(0)]); - line.replaceCells(2, 4, [6, 'f', 0, 'f'.charCodeAt(0)]); + line.replaceCells(2, 4, CellData.fromCharData([6, 'f', 0, 'f'.charCodeAt(0)])); chai.expect(line.toArray()).eql([ [1, 'a', 0, 'a'.charCodeAt(0)], [2, 'b', 0, 'b'.charCodeAt(0)], diff --git a/src/BufferLine.ts b/src/BufferLine.ts index fb1d40a9..d9ddae70 100644 --- a/src/BufferLine.ts +++ b/src/BufferLine.ts @@ -311,10 +311,9 @@ export class BufferLine implements IBufferLine { } } - public replaceCells(start: number, end: number, fillCharData: CharData): void { - this._cell.setFromCharData(fillCharData); + public replaceCells(start: number, end: number, fillCellData: ICellData): void { while (start < end && start < this.length) { - this.setCell(start++, this._cell); + this.setCell(start++, fillCellData); } } diff --git a/src/InputHandler.ts b/src/InputHandler.ts index 2776051d..37583602 100644 --- a/src/InputHandler.ts +++ b/src/InputHandler.ts @@ -7,7 +7,7 @@ import { IInputHandler, IDcsHandler, IEscapeSequenceParser, IBuffer, IInputHandlingTerminal } from './Types'; import { C0, C1 } from './common/data/EscapeSequences'; import { CHARSETS, DEFAULT_CHARSET } from './core/data/Charsets'; -import { DEFAULT_ATTR, NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE } from './Buffer'; +import { DEFAULT_ATTR, NULL_CELL_WIDTH, NULL_CELL_CODE } from './Buffer'; import { FLAGS } from './renderer/Types'; import { wcwidth } from './CharWidth'; import { EscapeSequenceParser } from './EscapeSequenceParser'; @@ -696,7 +696,7 @@ export class InputHandler extends Disposable implements IInputHandler { line.replaceCells( start, end, - [this._terminal.eraseAttr(), NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE] + this._terminal.buffer.getNullCell(this._terminal.eraseAttr()) ); if (clearWrap) { line.isWrapped = false; @@ -916,7 +916,7 @@ export class InputHandler extends Disposable implements IInputHandler { this._terminal.buffer.lines.get(this._terminal.buffer.y + this._terminal.buffer.ybase).replaceCells( this._terminal.buffer.x, this._terminal.buffer.x + (params[0] || 1), - [this._terminal.eraseAttr(), NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE] + this._terminal.buffer.getNullCell(this._terminal.eraseAttr()) ); } @@ -972,9 +972,10 @@ export class InputHandler extends Disposable implements IInputHandler { // make buffer local for faster access const buffer = this._terminal.buffer; const line = buffer.lines.get(buffer.ybase + buffer.y); + line.loadCell(buffer.x - 1, this._cell); line.replaceCells(buffer.x, buffer.x + (params[0] || 1), - line.get(buffer.x - 1) || [DEFAULT_ATTR, NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE] + (this._cell.content !== undefined) ? this._cell : buffer.getNullCell(DEFAULT_ATTR) ); // FIXME: no updateRange here? } diff --git a/src/Types.ts b/src/Types.ts index e991ac42..83f4e492 100644 --- a/src/Types.ts +++ b/src/Types.ts @@ -540,7 +540,7 @@ export interface IBufferLine { addCharToCell(index: number, codePoint: number): void; insertCells(pos: number, n: number, ch: ICellData): void; deleteCells(pos: number, n: number, fill: ICellData): void; - replaceCells(start: number, end: number, fill: CharData): void; + replaceCells(start: number, end: number, fill: ICellData): void; resize(cols: number, fill: CharData, shrink?: boolean): void; fill(fillCharData: CharData): void; copyFrom(line: IBufferLine): void;