Remove terminal dep in char joiner registry
This commit is contained in:
@@ -4,24 +4,19 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { assert } from 'chai';
|
import { assert } from 'chai';
|
||||||
|
|
||||||
import { MockTerminal, MockBuffer } from '../TestUtils.test';
|
|
||||||
import { CircularList } from 'common/CircularList';
|
|
||||||
|
|
||||||
import { ICharacterJoinerRegistry } from './Types';
|
import { ICharacterJoinerRegistry } from './Types';
|
||||||
import { CharacterJoinerRegistry } from './CharacterJoinerRegistry';
|
import { CharacterJoinerRegistry } from './CharacterJoinerRegistry';
|
||||||
import { BufferLine } from 'common/buffer/BufferLine';
|
import { BufferLine } from 'common/buffer/BufferLine';
|
||||||
import { IBufferLine } from 'common/Types';
|
import { IBufferLine } from 'common/Types';
|
||||||
import { CellData } from 'common/buffer/CellData';
|
import { CellData } from 'common/buffer/CellData';
|
||||||
|
import { MockBufferService } from 'common/TestUtils.test';
|
||||||
|
|
||||||
describe('CharacterJoinerRegistry', () => {
|
describe('CharacterJoinerRegistry', () => {
|
||||||
let registry: ICharacterJoinerRegistry;
|
let registry: ICharacterJoinerRegistry;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
const terminal = new MockTerminal();
|
const bufferService = new MockBufferService(16, 10);
|
||||||
terminal.cols = 16;
|
const lines = bufferService.buffer.lines;
|
||||||
terminal.buffer = new MockBuffer();
|
|
||||||
const lines = new CircularList<IBufferLine>(7);
|
|
||||||
lines.set(0, lineData([['a -> b -> c -> d']]));
|
lines.set(0, lineData([['a -> b -> c -> d']]));
|
||||||
lines.set(1, lineData([['a -> b => c -> d']]));
|
lines.set(1, lineData([['a -> b => c -> d']]));
|
||||||
lines.set(2, lineData([['a -> b -', 0xFFFFFFFF], ['> c -> d', 0]]));
|
lines.set(2, lineData([['a -> b -', 0xFFFFFFFF], ['> c -> d', 0]]));
|
||||||
@@ -44,9 +39,7 @@ describe('CharacterJoinerRegistry', () => {
|
|||||||
for (let i = 0; i < sub.length; ++i) line6.setCell(i + oldSize, sub.loadCell(i, new CellData()));
|
for (let i = 0; i < sub.length; ++i) line6.setCell(i + oldSize, sub.loadCell(i, new CellData()));
|
||||||
lines.set(6, line6);
|
lines.set(6, line6);
|
||||||
|
|
||||||
(<MockBuffer>terminal.buffer).setLines(lines);
|
registry = new CharacterJoinerRegistry(bufferService);
|
||||||
terminal.buffer.ydisp = 0;
|
|
||||||
registry = new CharacterJoinerRegistry(terminal);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('has no joiners upon creation', () => {
|
it('has no joiners upon creation', () => {
|
||||||
|
|||||||
@@ -3,12 +3,12 @@
|
|||||||
* @license MIT
|
* @license MIT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { ITerminal } from '../Types';
|
|
||||||
import { IBufferLine, ICellData, CharData } from 'common/Types';
|
import { IBufferLine, ICellData, CharData } from 'common/Types';
|
||||||
import { ICharacterJoinerRegistry, ICharacterJoiner } from './Types';
|
import { ICharacterJoinerRegistry, ICharacterJoiner } from './Types';
|
||||||
import { AttributeData } from 'common/buffer/AttributeData';
|
import { AttributeData } from 'common/buffer/AttributeData';
|
||||||
import { WHITESPACE_CELL_CHAR, Content } from 'common/buffer/Constants';
|
import { WHITESPACE_CELL_CHAR, Content } from 'common/buffer/Constants';
|
||||||
import { CellData } from 'common/buffer/CellData';
|
import { CellData } from 'common/buffer/CellData';
|
||||||
|
import { IBufferService } from 'common/services/Services';
|
||||||
|
|
||||||
export class JoinedCellData extends AttributeData implements ICellData {
|
export class JoinedCellData extends AttributeData implements ICellData {
|
||||||
private _width: number;
|
private _width: number;
|
||||||
@@ -61,8 +61,7 @@ export class CharacterJoinerRegistry implements ICharacterJoinerRegistry {
|
|||||||
private _nextCharacterJoinerId: number = 0;
|
private _nextCharacterJoinerId: number = 0;
|
||||||
private _workCell: CellData = new CellData();
|
private _workCell: CellData = new CellData();
|
||||||
|
|
||||||
constructor(private _terminal: ITerminal) {
|
constructor(private _bufferService: IBufferService) { }
|
||||||
}
|
|
||||||
|
|
||||||
public registerCharacterJoiner(handler: (text: string) => [number, number][]): number {
|
public registerCharacterJoiner(handler: (text: string) => [number, number][]): number {
|
||||||
const joiner: ICharacterJoiner = {
|
const joiner: ICharacterJoiner = {
|
||||||
@@ -90,7 +89,7 @@ export class CharacterJoinerRegistry implements ICharacterJoinerRegistry {
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
const line = this._terminal.buffer.lines.get(row);
|
const line = this._bufferService.buffer.lines.get(row);
|
||||||
if (line.length === 0) {
|
if (line.length === 0) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
@@ -144,7 +143,7 @@ export class CharacterJoinerRegistry implements ICharacterJoinerRegistry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Process any trailing ranges.
|
// Process any trailing ranges.
|
||||||
if (this._terminal.cols - rangeStartColumn > 1) {
|
if (this._bufferService.cols - rangeStartColumn > 1) {
|
||||||
const joinedRanges = this._getJoinedRanges(
|
const joinedRanges = this._getJoinedRanges(
|
||||||
lineStr,
|
lineStr,
|
||||||
rangeStartStringIndex,
|
rangeStartStringIndex,
|
||||||
@@ -204,7 +203,7 @@ export class CharacterJoinerRegistry implements ICharacterJoinerRegistry {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let x = startCol; x < this._terminal.cols; x++) {
|
for (let x = startCol; x < this._bufferService.cols; x++) {
|
||||||
const width = line.getWidth(x);
|
const width = line.getWidth(x);
|
||||||
const length = line.getString(x).length || WHITESPACE_CELL_CHAR.length;
|
const length = line.getString(x).length || WHITESPACE_CELL_CHAR.length;
|
||||||
|
|
||||||
@@ -252,7 +251,7 @@ export class CharacterJoinerRegistry implements ICharacterJoinerRegistry {
|
|||||||
// If there is still a range left at the end, it must extend all the way to
|
// If there is still a range left at the end, it must extend all the way to
|
||||||
// the end of the line.
|
// the end of the line.
|
||||||
if (currentRange) {
|
if (currentRange) {
|
||||||
currentRange[1] = this._terminal.cols;
|
currentRange[1] = this._bufferService.cols;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user