mirror of
https://github.com/wavetermdev/xterm.js.git
synced 2026-08-05 13:43:48 -07:00
change insertCells to new interface
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
* @license MIT
|
||||
*/
|
||||
import * as chai from 'chai';
|
||||
import { BufferLine } from './BufferLine';
|
||||
import { BufferLine, CellData } from './BufferLine';
|
||||
import { CharData, IBufferLine } from './Types';
|
||||
import { NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE, DEFAULT_ATTR } from './Buffer';
|
||||
|
||||
@@ -41,7 +41,7 @@ describe('BufferLine', function(): void {
|
||||
line.set(0, [1, 'a', 0, 'a'.charCodeAt(0)]);
|
||||
line.set(1, [2, 'b', 0, 'b'.charCodeAt(0)]);
|
||||
line.set(2, [3, 'c', 0, 'c'.charCodeAt(0)]);
|
||||
line.insertCells(1, 3, [4, 'd', 0, 'd'.charCodeAt(0)]);
|
||||
line.insertCells(1, 3, CellData.fromCharData([4, 'd', 0, 'd'.charCodeAt(0)]));
|
||||
chai.expect(line.toArray()).eql([
|
||||
[1, 'a', 0, 'a'.charCodeAt(0)],
|
||||
[4, 'd', 0, 'd'.charCodeAt(0)],
|
||||
|
||||
+3
-5
@@ -279,20 +279,18 @@ export class BufferLine implements IBufferLine {
|
||||
}
|
||||
}
|
||||
|
||||
public insertCells(pos: number, n: number, fillCharData: CharData): void {
|
||||
public insertCells(pos: number, n: number, fillCellData: ICellData): void {
|
||||
pos %= this.length;
|
||||
if (n < this.length - pos) {
|
||||
for (let i = this.length - pos - n - 1; i >= 0; --i) {
|
||||
this.setCell(pos + n + i, this.loadCell(pos + i, this._cell));
|
||||
}
|
||||
this._cell.setFromCharData(fillCharData);
|
||||
for (let i = 0; i < n; ++i) {
|
||||
this.setCell(pos + i, this._cell);
|
||||
this.setCell(pos + i, fillCellData);
|
||||
}
|
||||
} else {
|
||||
this._cell.setFromCharData(fillCharData);
|
||||
for (let i = pos; i < this.length; ++i) {
|
||||
this.setCell(i, this._cell);
|
||||
this.setCell(i, fillCellData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+8
-2
@@ -396,7 +396,10 @@ export class InputHandler extends Disposable implements IInputHandler {
|
||||
// insert mode: move characters to right
|
||||
if (insertMode) {
|
||||
// right shift cells according to the width
|
||||
bufferRow.insertCells(buffer.x, chWidth, [curAttr, NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE]);
|
||||
this._cell.fg = curAttr;
|
||||
this._cell.bg = 0;
|
||||
this._cell.content = 0;
|
||||
bufferRow.insertCells(buffer.x, chWidth, this._cell);
|
||||
// test last cell - since the last cell has only room for
|
||||
// a halfwidth char any fullwidth shifted there is lost
|
||||
// and will be set to eraseChar
|
||||
@@ -516,10 +519,13 @@ export class InputHandler extends Disposable implements IInputHandler {
|
||||
* Insert Ps (Blank) Character(s) (default = 1) (ICH).
|
||||
*/
|
||||
public insertChars(params: number[]): void {
|
||||
this._cell.content = 0;
|
||||
this._cell.fg = this._terminal.eraseAttr();
|
||||
this._cell.bg = 0;
|
||||
this._terminal.buffer.lines.get(this._terminal.buffer.y + this._terminal.buffer.ybase).insertCells(
|
||||
this._terminal.buffer.x,
|
||||
params[0] || 1,
|
||||
[this._terminal.eraseAttr(), NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE]
|
||||
this._cell
|
||||
);
|
||||
this._terminal.updateRange(this._terminal.buffer.y);
|
||||
}
|
||||
|
||||
+1
-1
@@ -536,7 +536,7 @@ export interface IBufferLine {
|
||||
setCell(index: number, cell: ICellData): void;
|
||||
setDataFromCodePoint(index: number, codePoint: number, width: number, fg: number, bg: number): void;
|
||||
addCharToCell(index: number, codePoint: number): void;
|
||||
insertCells(pos: number, n: number, ch: CharData): void;
|
||||
insertCells(pos: number, n: number, ch: ICellData): void;
|
||||
deleteCells(pos: number, n: number, fill: CharData): void;
|
||||
replaceCells(start: number, end: number, fill: CharData): void;
|
||||
resize(cols: number, fill: CharData, shrink?: boolean): void;
|
||||
|
||||
Reference in New Issue
Block a user