remove static DefaultCell
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
* @license MIT
|
* @license MIT
|
||||||
*/
|
*/
|
||||||
import * as chai from 'chai';
|
import * as chai from 'chai';
|
||||||
import { BufferLine } from './BufferLine';
|
import { BufferLine, DEFAULT_CELL } from './BufferLine';
|
||||||
import { CharData, IBufferLine } from './Types';
|
import { CharData, IBufferLine } from './Types';
|
||||||
import { NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE, CHAR_DATA_ATTR_INDEX, CHAR_DATA_CHAR_INDEX, CHAR_DATA_WIDTH_INDEX, CHAR_DATA_CODE_INDEX } from './Buffer';
|
import { NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE, CHAR_DATA_ATTR_INDEX, CHAR_DATA_CHAR_INDEX, CHAR_DATA_WIDTH_INDEX, CHAR_DATA_CODE_INDEX } from './Buffer';
|
||||||
|
|
||||||
@@ -22,11 +22,11 @@ describe('BufferLine', function(): void {
|
|||||||
chai.expect(line.isWrapped).equals(false);
|
chai.expect(line.isWrapped).equals(false);
|
||||||
line = new TestBufferLine(10);
|
line = new TestBufferLine(10);
|
||||||
chai.expect(line.length).equals(10);
|
chai.expect(line.length).equals(10);
|
||||||
chai.expect(line.pop()).eql(TestBufferLine.defaultCell);
|
chai.expect(line.pop()).eql(DEFAULT_CELL);
|
||||||
chai.expect(line.isWrapped).equals(false);
|
chai.expect(line.isWrapped).equals(false);
|
||||||
line = new TestBufferLine(10, null, true);
|
line = new TestBufferLine(10, null, true);
|
||||||
chai.expect(line.length).equals(10);
|
chai.expect(line.length).equals(10);
|
||||||
chai.expect(line.pop()).eql(TestBufferLine.defaultCell);
|
chai.expect(line.pop()).eql(DEFAULT_CELL);
|
||||||
chai.expect(line.isWrapped).equals(true);
|
chai.expect(line.isWrapped).equals(true);
|
||||||
line = new TestBufferLine(10, [123, 'a', 456, 789], true);
|
line = new TestBufferLine(10, [123, 'a', 456, 789], true);
|
||||||
chai.expect(line.length).equals(10);
|
chai.expect(line.length).equals(10);
|
||||||
|
|||||||
+2
-3
@@ -5,13 +5,12 @@
|
|||||||
import { CharData, IBufferLine } from './Types';
|
import { CharData, IBufferLine } from './Types';
|
||||||
import { NULL_CELL_CODE, NULL_CELL_WIDTH, NULL_CELL_CHAR } from './Buffer';
|
import { NULL_CELL_CODE, NULL_CELL_WIDTH, NULL_CELL_CHAR } from './Buffer';
|
||||||
|
|
||||||
export const defaultCell: CharData = [0, NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE];
|
export const DEFAULT_CELL: CharData = [0, NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class representing a terminal line.
|
* Class representing a terminal line.
|
||||||
*/
|
*/
|
||||||
export class BufferLine implements IBufferLine {
|
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): IBufferLine {
|
static blankLine(cols: number, attr: number, isWrapped?: boolean): IBufferLine {
|
||||||
const ch: CharData = [attr, NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE];
|
const ch: CharData = [attr, NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE];
|
||||||
return new BufferLine(cols, ch, isWrapped);
|
return new BufferLine(cols, ch, isWrapped);
|
||||||
@@ -25,7 +24,7 @@ export class BufferLine implements IBufferLine {
|
|||||||
this.length = this._data.length;
|
this.length = this._data.length;
|
||||||
if (cols) {
|
if (cols) {
|
||||||
if (!ch) {
|
if (!ch) {
|
||||||
ch = BufferLine.defaultCell;
|
ch = DEFAULT_CELL;
|
||||||
}
|
}
|
||||||
for (let i = 0; i < cols; i++) {
|
for (let i = 0; i < cols; i++) {
|
||||||
this.push(ch); // Note: the ctor ch is not cloned
|
this.push(ch); // Note: the ctor ch is not cloned
|
||||||
|
|||||||
Reference in New Issue
Block a user