Expose underline attrs as getter/setter

In preparation for storing them in a packed format for glyph caching
This commit is contained in:
Daniel Imms
2022-07-23 07:13:29 -07:00
parent 1207acc495
commit cc8748313e
2 changed files with 22 additions and 7 deletions
+21 -6
View File
@@ -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);
+1 -1
View File
@@ -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) {