Skip to content

Commit

Permalink
Move BufferLine into core
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyriar committed May 10, 2019
1 parent 7b7fc53 commit 228ec7b
Show file tree
Hide file tree
Showing 24 changed files with 32 additions and 35 deletions.
2 changes: 1 addition & 1 deletion src/Buffer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { ITerminal } from './Types';
import { Buffer } from './Buffer';
import { CircularList } from './common/CircularList';
import { MockTerminal, TestTerminal } from './TestUtils.test';
import { BufferLine, CellData, DEFAULT_ATTR_DATA } from './BufferLine';
import { BufferLine, CellData, DEFAULT_ATTR_DATA } from './core/buffer/BufferLine';

const INIT_COLS = 80;
const INIT_ROWS = 24;
Expand Down
2 changes: 1 addition & 1 deletion src/Buffer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { CircularList, IInsertEvent } from './common/CircularList';
import { ITerminal, IBuffer, BufferIndex, IBufferStringIterator, IBufferStringIteratorResult } from './Types';
import { IBufferLine, ICellData, IAttributeData } from './core/Types';
import { IMarker } from 'xterm';
import { BufferLine, CellData, NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE, WHITESPACE_CELL_CHAR, WHITESPACE_CELL_WIDTH, WHITESPACE_CELL_CODE, CHAR_DATA_WIDTH_INDEX, CHAR_DATA_CHAR_INDEX, DEFAULT_ATTR_DATA } from './BufferLine';
import { BufferLine, CellData, NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE, WHITESPACE_CELL_CHAR, WHITESPACE_CELL_WIDTH, WHITESPACE_CELL_CODE, CHAR_DATA_WIDTH_INDEX, CHAR_DATA_CHAR_INDEX, DEFAULT_ATTR_DATA } from './core/buffer/BufferLine';
import { reflowLargerApplyNewLayout, reflowLargerCreateNewLayout, reflowLargerGetLinesToRemove, reflowSmallerGetNewLineLengths, getWrappedLineTrimmedLength } from './BufferReflow';
import { EventEmitter2, IEvent } from './common/EventEmitter2';
import { Disposable } from '../lib/common/Lifecycle';
Expand Down
3 changes: 1 addition & 2 deletions src/BufferLine.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
* @license MIT
*/
import * as chai from 'chai';
import { BufferLine, CellData, Content, NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE, DEFAULT_ATTR } from './BufferLine';
import { BufferLine, CellData, Content, NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE, DEFAULT_ATTR } from './core/buffer/BufferLine';
import { CharData, IBufferLine } from './core/Types';


class TestBufferLine extends BufferLine {
public get combined(): {[index: number]: string} {
return this._combined;
Expand Down
2 changes: 1 addition & 1 deletion src/BufferReflow.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @license MIT
*/
import { assert } from 'chai';
import { BufferLine, NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE } from './BufferLine';
import { BufferLine, NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE } from './core/buffer/BufferLine';
import { reflowSmallerGetNewLineLengths } from './BufferReflow';

describe('BufferReflow', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/BufferReflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @license MIT
*/

import { BufferLine } from './BufferLine';
import { BufferLine } from './core/buffer/BufferLine';
import { CircularList } from './common/CircularList';
import { IBufferLine, ICellData } from './core/Types';

Expand Down
2 changes: 1 addition & 1 deletion src/CharWidth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { TestTerminal } from './TestUtils.test';
import { assert } from 'chai';
import { getStringCellWidth, wcwidth } from './CharWidth';
import { IBuffer } from './Types';
import { CellData, CHAR_DATA_WIDTH_INDEX, CHAR_DATA_CHAR_INDEX } from './BufferLine';
import { CellData, CHAR_DATA_WIDTH_INDEX, CHAR_DATA_CHAR_INDEX } from './core/buffer/BufferLine';


describe('getStringCellWidth', function(): void {
Expand Down
2 changes: 1 addition & 1 deletion src/InputHandler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { InputHandler } from './InputHandler';
import { MockInputHandlingTerminal, TestTerminal } from './TestUtils.test';
import { Terminal } from './Terminal';
import { IBufferLine } from './core/Types';
import { CellData, Attributes, AttributeData, DEFAULT_ATTR_DATA } from './BufferLine';
import { CellData, Attributes, AttributeData, DEFAULT_ATTR_DATA } from './core/buffer/BufferLine';

describe('InputHandler', () => {
describe('save and restore cursor', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/InputHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { IDisposable } from 'xterm';
import { Disposable } from './common/Lifecycle';
import { concat } from './common/TypedArrayUtils';
import { StringToUtf32, stringFromCodePoint, utf32ToString } from './core/input/TextDecoder';
import { CellData, Attributes, FgFlags, BgFlags, AttributeData, NULL_CELL_WIDTH, NULL_CELL_CODE, DEFAULT_ATTR_DATA } from './BufferLine';
import { CellData, Attributes, FgFlags, BgFlags, AttributeData, NULL_CELL_WIDTH, NULL_CELL_CODE, DEFAULT_ATTR_DATA } from './core/buffer/BufferLine';
import { EventEmitter2, IEvent } from './common/EventEmitter2';

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Linkifier.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { IBufferLine } from './core/Types';
import { Linkifier } from './Linkifier';
import { MockBuffer, MockTerminal, TestTerminal } from './TestUtils.test';
import { CircularList } from './common/CircularList';
import { BufferLine, CellData } from './BufferLine';
import { BufferLine, CellData } from './core/buffer/BufferLine';

class TestLinkifier extends Linkifier {
constructor(terminal: ITerminal) {
Expand Down
2 changes: 1 addition & 1 deletion src/SelectionManager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { BufferSet } from './BufferSet';
import { ITerminal, IBuffer } from './Types';
import { IBufferLine } from './core/Types';
import { MockTerminal } from './TestUtils.test';
import { BufferLine, CellData } from './BufferLine';
import { BufferLine, CellData } from './core/buffer/BufferLine';

class TestMockTerminal extends MockTerminal {
emit(event: string, data: any): void {}
Expand Down
2 changes: 1 addition & 1 deletion src/SelectionManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import * as Browser from './common/Platform';
import { CharMeasure } from './CharMeasure';
import { SelectionModel } from './SelectionModel';
import { AltClickHandler } from './handlers/AltClickHandler';
import { CellData } from './BufferLine';
import { CellData } from './core/buffer/BufferLine';
import { IDisposable } from 'xterm';
import { EventEmitter2, IEvent } from './common/EventEmitter2';

Expand Down
2 changes: 1 addition & 1 deletion src/Terminal.integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import * as pty from 'node-pty';
import { assert } from 'chai';
import { Terminal } from './Terminal';
import { IViewport } from './Types';
import { CellData, WHITESPACE_CELL_CHAR } from './BufferLine';
import { CellData, WHITESPACE_CELL_CHAR } from './core/buffer/BufferLine';

class TestTerminal extends Terminal {
innerWrite(): void { this._innerWrite(); }
Expand Down
2 changes: 1 addition & 1 deletion src/Terminal.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { assert, expect } from 'chai';
import { Terminal } from './Terminal';
import { MockViewport, MockCompositionHelper, MockRenderer } from './TestUtils.test';
import { CellData, DEFAULT_ATTR_DATA } from './BufferLine';
import { CellData, DEFAULT_ATTR_DATA } from './core/buffer/BufferLine';

const INIT_COLS = 80;
const INIT_ROWS = 24;
Expand Down
2 changes: 1 addition & 1 deletion src/Terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ import { evaluateKeyboardEvent } from './core/input/Keyboard';
import { KeyboardResultType, ICharset, IBufferLine, IAttributeData } from './core/Types';
import { clone } from './common/Clone';
import { EventEmitter2, IEvent } from './common/EventEmitter2';
import { Attributes, DEFAULT_ATTR_DATA } from './BufferLine';
import { Attributes, DEFAULT_ATTR_DATA } from './core/buffer/BufferLine';
import { applyWindowsMode } from './WindowsMode';

// Let it work inside Node.js for automated testing purposes.
Expand Down
2 changes: 1 addition & 1 deletion src/TestUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { Buffer } from './Buffer';
import * as Browser from './common/Platform';
import { ITheme, IDisposable, IMarker, IEvent } from 'xterm';
import { Terminal } from './Terminal';
import { AttributeData } from './BufferLine';
import { AttributeData } from './core/buffer/BufferLine';

export class TestTerminal extends Terminal {
writeSync(data: string): void {
Expand Down
2 changes: 1 addition & 1 deletion src/WindowsMode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import { IDisposable } from 'xterm';
import { ITerminal } from './Types';
import { CHAR_DATA_CODE_INDEX, NULL_CELL_CODE, WHITESPACE_CELL_CODE } from './BufferLine';
import { CHAR_DATA_CODE_INDEX, NULL_CELL_CODE, WHITESPACE_CELL_CODE } from './core/buffer/BufferLine';

export function applyWindowsMode(terminal: ITerminal): IDisposable {
// Winpty does not support wraparound mode which means that lines will never
Expand Down
20 changes: 9 additions & 11 deletions src/BufferLine.ts → src/core/buffer/BufferLine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
* Copyright (c) 2018 The xterm.js authors. All rights reserved.
* @license MIT
*/
import { CharData, IBufferLine, ICellData, IColorRGB, IAttributeData } from './core/Types';
import { stringFromCodePoint } from './core/input/TextDecoder';
import { DEFAULT_COLOR } from './common/Types';
import { CharData, IBufferLine, ICellData, IColorRGB, IAttributeData } from '../Types';
import { stringFromCodePoint } from '../input/TextDecoder';
import { DEFAULT_COLOR } from '../../common/Types';

export const DEFAULT_ATTR = (0 << 18) | (DEFAULT_COLOR << 9) | (256 << 0);

Expand Down Expand Up @@ -325,17 +325,15 @@ export class CellData extends AttributeData implements ICellData {
* memory allocs / GC pressure can be greatly reduced by reusing the CellData object.
*/
export class BufferLine implements IBufferLine {
protected _data: Uint32Array | null = null;
protected _data: Uint32Array;
protected _combined: {[index: number]: string} = {};
public length: number;

constructor(cols: number, fillCellData?: ICellData, public isWrapped: boolean = false) {
if (cols) {
this._data = new Uint32Array(cols * CELL_SIZE);
const cell = fillCellData || CellData.fromCharData([0, NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE]);
for (let i = 0; i < cols; ++i) {
this.setCell(i, cell);
}
this._data = new Uint32Array(cols * CELL_SIZE);
const cell = fillCellData || CellData.fromCharData([0, NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE]);
for (let i = 0; i < cols; ++i) {
this.setCell(i, cell);
}
this.length = cols;
}
Expand Down Expand Up @@ -573,7 +571,7 @@ export class BufferLine implements IBufferLine {
}
}
} else {
this._data = null;
this._data = new Uint32Array(0);
this._combined = {};
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/BaseRenderLayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { DEFAULT_COLOR } from '../common/Types';
import { DIM_OPACITY, INVERTED_DEFAULT_COLOR, IGlyphIdentifier } from './atlas/Types';
import BaseCharAtlas from './atlas/BaseCharAtlas';
import { acquireCharAtlas } from './atlas/CharAtlasCache';
import { CellData, AttributeData, WHITESPACE_CELL_CHAR, WHITESPACE_CELL_CODE } from '../BufferLine';
import { CellData, AttributeData, WHITESPACE_CELL_CHAR, WHITESPACE_CELL_CODE } from '../core/buffer/BufferLine';
import { JoinedCellData } from './CharacterJoinerRegistry';

export abstract class BaseRenderLayer implements IRenderLayer {
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/CharacterJoinerRegistry.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { CircularList } from '../common/CircularList';

import { ICharacterJoinerRegistry } from './Types';
import { CharacterJoinerRegistry } from './CharacterJoinerRegistry';
import { BufferLine, CellData } from '../BufferLine';
import { BufferLine, CellData } from '../core/buffer/BufferLine';
import { IBufferLine } from '../core/Types';

describe('CharacterJoinerRegistry', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/CharacterJoinerRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { ITerminal } from '../Types';
import { IBufferLine, ICellData, CharData } from '../core/Types';
import { ICharacterJoinerRegistry, ICharacterJoiner } from './Types';
import { CellData, Content, AttributeData, WHITESPACE_CELL_CHAR } from '../BufferLine';
import { CellData, Content, AttributeData, WHITESPACE_CELL_CHAR } from '../core/buffer/BufferLine';

export class JoinedCellData extends AttributeData implements ICellData {
private _width: number;
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/CursorRenderLayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { IColorSet, IRenderDimensions } from './Types';
import { BaseRenderLayer } from './BaseRenderLayer';
import { ITerminal } from '../Types';
import { ICellData } from '../core/Types';
import { CellData } from '../BufferLine';
import { CellData } from '../core/buffer/BufferLine';

interface ICursorState {
x: number;
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/TextRenderLayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { ITerminal } from '../Types';
import { CharData, ICellData } from '../core/Types';
import { GridCache } from './GridCache';
import { BaseRenderLayer } from './BaseRenderLayer';
import { CellData, AttributeData, Content, NULL_CELL_CODE } from '../BufferLine';
import { CellData, AttributeData, Content, NULL_CELL_CODE } from '../core/buffer/BufferLine';
import { JoinedCellData } from './CharacterJoinerRegistry';

/**
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/dom/DomRendererRowFactory.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import jsdom = require('jsdom');
import { assert } from 'chai';
import { DomRendererRowFactory } from './DomRendererRowFactory';
import { BufferLine, CellData, FgFlags, BgFlags, Attributes, NULL_CELL_CODE, NULL_CELL_WIDTH, NULL_CELL_CHAR, DEFAULT_ATTR, DEFAULT_ATTR_DATA } from '../../BufferLine';
import { BufferLine, CellData, FgFlags, BgFlags, Attributes, NULL_CELL_CODE, NULL_CELL_WIDTH, NULL_CELL_CHAR, DEFAULT_ATTR, DEFAULT_ATTR_DATA } from '../../core/buffer/BufferLine';
import { ITerminalOptions } from '../../Types';
import { IBufferLine } from '../../core/Types';

Expand Down
2 changes: 1 addition & 1 deletion src/renderer/dom/DomRendererRowFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { ITerminalOptions } from '../../Types';
import { IBufferLine } from '../../core/Types';
import { INVERTED_DEFAULT_COLOR } from '../atlas/Types';
import { CellData, AttributeData, NULL_CELL_CODE, WHITESPACE_CELL_CHAR } from '../../BufferLine';
import { CellData, AttributeData, NULL_CELL_CODE, WHITESPACE_CELL_CHAR } from '../../core/buffer/BufferLine';

export const BOLD_CLASS = 'xterm-bold';
export const DIM_CLASS = 'xterm-dim';
Expand Down

0 comments on commit 228ec7b

Please sign in to comment.