Merge pull request #2035 from jerch/2028_handle_joined_cells
cell representation for joined cells
This commit is contained in:
@@ -10,6 +10,7 @@ import BaseCharAtlas from './atlas/BaseCharAtlas';
|
|||||||
import { acquireCharAtlas } from './atlas/CharAtlasCache';
|
import { acquireCharAtlas } from './atlas/CharAtlasCache';
|
||||||
import { CellData, AttributeData } from '../BufferLine';
|
import { CellData, AttributeData } from '../BufferLine';
|
||||||
import { WHITESPACE_CELL_CHAR, WHITESPACE_CELL_CODE } from '../Buffer';
|
import { WHITESPACE_CELL_CHAR, WHITESPACE_CELL_CODE } from '../Buffer';
|
||||||
|
import { JoinedCellData } from './CharacterJoinerRegistry';
|
||||||
|
|
||||||
export abstract class BaseRenderLayer implements IRenderLayer {
|
export abstract class BaseRenderLayer implements IRenderLayer {
|
||||||
private _canvas: HTMLCanvasElement;
|
private _canvas: HTMLCanvasElement;
|
||||||
@@ -261,7 +262,10 @@ export abstract class BaseRenderLayer implements IRenderLayer {
|
|||||||
protected drawChars(terminal: ITerminal, cell: ICellData, x: number, y: number): void {
|
protected drawChars(terminal: ITerminal, cell: ICellData, x: number, y: number): void {
|
||||||
|
|
||||||
// skip cache right away if we draw in RGB
|
// skip cache right away if we draw in RGB
|
||||||
if (cell.isFgRGB() || cell.isBgRGB()) {
|
// Note: to avoid bad runtime JoinedCellData will be skipped
|
||||||
|
// in the cache handler (atlasDidDraw == false) itself and
|
||||||
|
// fall through to uncached later down below
|
||||||
|
if (cell.isFgRGB() || cell.isBgRGB() || cell instanceof JoinedCellData) {
|
||||||
this._drawUncachedChars(terminal, cell, x, y);
|
this._drawUncachedChars(terminal, cell, x, y);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,53 @@
|
|||||||
import { ITerminal, IBufferLine } from '../Types';
|
import { ITerminal, IBufferLine, ICellData, CharData } from '../Types';
|
||||||
import { ICharacterJoinerRegistry, ICharacterJoiner } from './Types';
|
import { ICharacterJoinerRegistry, ICharacterJoiner } from './Types';
|
||||||
import { CellData } from '../BufferLine';
|
import { CellData, Content, AttributeData } from '../BufferLine';
|
||||||
import { WHITESPACE_CELL_CHAR } from '../Buffer';
|
import { WHITESPACE_CELL_CHAR } from '../Buffer';
|
||||||
|
|
||||||
|
export class JoinedCellData extends AttributeData implements ICellData {
|
||||||
|
private _width: number;
|
||||||
|
// .content carries no meaning for joined CellData, simply nullify it
|
||||||
|
// thus we have to overload all other .content accessors
|
||||||
|
public content: number = 0;
|
||||||
|
public fg: number;
|
||||||
|
public bg: number;
|
||||||
|
public combinedData: string = '';
|
||||||
|
|
||||||
|
constructor(firstCell: ICellData, chars: string, width: number) {
|
||||||
|
super();
|
||||||
|
this.fg = firstCell.fg;
|
||||||
|
this.bg = firstCell.bg;
|
||||||
|
this.combinedData = chars;
|
||||||
|
this._width = width;
|
||||||
|
}
|
||||||
|
|
||||||
|
public isCombined(): number {
|
||||||
|
// always mark joined cell data as combined
|
||||||
|
return Content.IS_COMBINED_MASK;
|
||||||
|
}
|
||||||
|
|
||||||
|
public getWidth(): number {
|
||||||
|
return this._width;
|
||||||
|
}
|
||||||
|
|
||||||
|
public getChars(): string {
|
||||||
|
return this.combinedData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public getCode(): number {
|
||||||
|
// code always gets the highest possible fake codepoint (read as -1)
|
||||||
|
// this is needed as code is used by caches as identifier
|
||||||
|
return 0x1FFFFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
public setFromCharData(value: CharData): void {
|
||||||
|
throw new Error('not implemented');
|
||||||
|
}
|
||||||
|
|
||||||
|
public getAsCharData(): CharData {
|
||||||
|
return [this.fg, this.getChars(), this.getWidth(), this.getCode()];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export class CharacterJoinerRegistry implements ICharacterJoinerRegistry {
|
export class CharacterJoinerRegistry implements ICharacterJoinerRegistry {
|
||||||
|
|
||||||
private _characterJoiners: ICharacterJoiner[] = [];
|
private _characterJoiners: ICharacterJoiner[] = [];
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import { CharData, ITerminal, ICellData } from '../Types';
|
|||||||
import { GridCache } from './GridCache';
|
import { GridCache } from './GridCache';
|
||||||
import { BaseRenderLayer } from './BaseRenderLayer';
|
import { BaseRenderLayer } from './BaseRenderLayer';
|
||||||
import { CellData, AttributeData, Content } from '../BufferLine';
|
import { CellData, AttributeData, Content } from '../BufferLine';
|
||||||
|
import { JoinedCellData } from './CharacterJoinerRegistry';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This CharData looks like a null character, which will forc a clear and render
|
* This CharData looks like a null character, which will forc a clear and render
|
||||||
@@ -89,15 +90,12 @@ export class TextRenderLayer extends BaseRenderLayer {
|
|||||||
|
|
||||||
// We already know the exact start and end column of the joined range,
|
// We already know the exact start and end column of the joined range,
|
||||||
// so we get the string and width representing it directly
|
// so we get the string and width representing it directly
|
||||||
cell = CellData.fromCharData([
|
|
||||||
0,
|
cell = new JoinedCellData(
|
||||||
|
this._workCell,
|
||||||
line.translateToString(true, range[0], range[1]),
|
line.translateToString(true, range[0], range[1]),
|
||||||
range[1] - range[0],
|
range[1] - range[0]
|
||||||
0xFFFFFF
|
);
|
||||||
]);
|
|
||||||
// hacky: patch attrs
|
|
||||||
cell.fg = this._workCell.fg;
|
|
||||||
cell.bg = this._workCell.bg;
|
|
||||||
|
|
||||||
// Skip over the cells occupied by this range in the loop
|
// Skip over the cells occupied by this range in the loop
|
||||||
lastCharX = range[1] - 1;
|
lastCharX = range[1] - 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user