From cc8748313e6f294bc936a6aae64ba4810239e880 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Sat, 23 Jul 2022 07:13:29 -0700 Subject: [PATCH] Expose underline attrs as getter/setter In preparation for storing them in a packed format for glyph caching --- src/common/buffer/AttributeData.ts | 27 +++++++++++++++++++++------ src/common/buffer/BufferLine.ts | 2 +- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/common/buffer/AttributeData.ts b/src/common/buffer/AttributeData.ts index 43d378ea..1ee608a7 100644 --- a/src/common/buffer/AttributeData.ts +++ b/src/common/buffer/AttributeData.ts @@ -30,7 +30,7 @@ export class AttributeData implements IAttributeData { // data public fg = 0; public bg = 0; - public extended = new ExtendedAttrs(); + public extended: IExtendedAttrs = new ExtendedAttrs(); // flags public isInverse(): number { return this.fg & FgFlags.INVERSE; } @@ -127,12 +127,27 @@ export class AttributeData implements IAttributeData { * Holds information about different underline styles and color. */ export class ExtendedAttrs implements IExtendedAttrs { + // underline style, NONE is empty + private _underlineStyle: UnderlineStyle = UnderlineStyle.NONE; + public get underlineStyle(): UnderlineStyle { return this._underlineStyle; } + public set underlineStyle(value: UnderlineStyle) { + this._underlineStyle = value; + } + + // underline color, -1 is empty (same as FG) + private _underlineColor: number = -1; + public get underlineColor(): number { return this._underlineColor; } + public set underlineColor(value: number) { + this._underlineColor = value; + } + constructor( - // underline style, NONE is empty - public underlineStyle: UnderlineStyle = UnderlineStyle.NONE, - // underline color, -1 is empty (same as FG) - public underlineColor: number = -1 - ) {} + underlineStyle: UnderlineStyle = UnderlineStyle.NONE, + underlineColor: number = -1 + ) { + this._underlineStyle = underlineStyle; + this._underlineColor = underlineColor; + } public clone(): IExtendedAttrs { return new ExtendedAttrs(this.underlineStyle, this.underlineColor); diff --git a/src/common/buffer/BufferLine.ts b/src/common/buffer/BufferLine.ts index f0bf4fcb..6d2a442f 100644 --- a/src/common/buffer/BufferLine.ts +++ b/src/common/buffer/BufferLine.ts @@ -55,7 +55,7 @@ export const DEFAULT_ATTR_DATA = Object.freeze(new AttributeData()); export class BufferLine implements IBufferLine { protected _data: Uint32Array; protected _combined: {[index: number]: string} = {}; - protected _extendedAttrs: {[index: number]: ExtendedAttrs} = {}; + protected _extendedAttrs: {[index: number]: IExtendedAttrs} = {}; public length: number; constructor(cols: number, fillCellData?: ICellData, public isWrapped: boolean = false) {