mirror of
https://github.com/wavetermdev/xterm.js.git
synced 2026-08-05 13:43:48 -07:00
jix joined cell representation as overloaded CellData type
This commit is contained in:
@@ -10,6 +10,7 @@ import BaseCharAtlas from './atlas/BaseCharAtlas';
|
||||
import { acquireCharAtlas } from './atlas/CharAtlasCache';
|
||||
import { CellData, AttributeData } from '../BufferLine';
|
||||
import { WHITESPACE_CELL_CHAR, WHITESPACE_CELL_CODE } from '../Buffer';
|
||||
import { JoinedCellData } from './CharacterJoinerRegistry';
|
||||
|
||||
export abstract class BaseRenderLayer implements IRenderLayer {
|
||||
private _canvas: HTMLCanvasElement;
|
||||
@@ -260,8 +261,8 @@ export abstract class BaseRenderLayer implements IRenderLayer {
|
||||
*/
|
||||
protected drawChars(terminal: ITerminal, cell: ICellData, x: number, y: number): void {
|
||||
|
||||
// skip cache right away if we draw in RGB
|
||||
if (cell.isFgRGB() || cell.isBgRGB()) {
|
||||
// skip cache right away if we draw in RGB or have joined cells
|
||||
if (cell.isFgRGB() || cell.isBgRGB() || cell instanceof JoinedCellData) {
|
||||
this._drawUncachedChars(terminal, cell, x, y);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,51 @@
|
||||
import { ITerminal, IBufferLine } from '../Types';
|
||||
import { ITerminal, IBufferLine, ICellData, CharData } from '../Types';
|
||||
import { ICharacterJoinerRegistry, ICharacterJoiner } from './Types';
|
||||
import { CellData } from '../BufferLine';
|
||||
import { CellData, Content } from '../BufferLine';
|
||||
import { WHITESPACE_CELL_CHAR } from '../Buffer';
|
||||
|
||||
export class JoinedCellData extends CellData implements ICellData {
|
||||
private _width: number = 0;
|
||||
private _code: number = 0x1FFFFF; // highest allowed codepoint, meant as -1
|
||||
|
||||
public content: number = 0;
|
||||
public fg: number = 0;
|
||||
public bg: number = 0;
|
||||
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 {
|
||||
return this._code;
|
||||
}
|
||||
|
||||
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 {
|
||||
|
||||
private _characterJoiners: ICharacterJoiner[] = [];
|
||||
|
||||
@@ -9,6 +9,7 @@ import { CharData, ITerminal, ICellData } from '../Types';
|
||||
import { GridCache } from './GridCache';
|
||||
import { BaseRenderLayer } from './BaseRenderLayer';
|
||||
import { CellData, AttributeData, Content } from '../BufferLine';
|
||||
import { JoinedCellData } from './CharacterJoinerRegistry';
|
||||
|
||||
/**
|
||||
* 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,
|
||||
// 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]),
|
||||
range[1] - range[0],
|
||||
0xFFFFFF
|
||||
]);
|
||||
// hacky: patch attrs
|
||||
cell.fg = this._workCell.fg;
|
||||
cell.bg = this._workCell.bg;
|
||||
range[1] - range[0]
|
||||
);
|
||||
|
||||
// Skip over the cells occupied by this range in the loop
|
||||
lastCharX = range[1] - 1;
|
||||
|
||||
Reference in New Issue
Block a user