Store extended attributes in single number

This commit is contained in:
Daniel Imms
2022-07-23 11:12:17 -07:00
parent 8cd01dc421
commit 03f15a7fb7
5 changed files with 28 additions and 15 deletions
@@ -384,8 +384,7 @@ export class WebglRenderer extends Disposable implements IRenderer {
private _loadColorsForCell(x: number, y: number): void {
this._workColors.bg = this._workCell.bg;
this._workColors.fg = this._workCell.fg;
// TODO: Use extended packed format as key
this._workColors.ext = this._workCell.extended.underlineStyle;
this._workColors.ext = this._workCell.extended.ext;
// Get any foreground/background overrides, this happens on the model to avoid spreading
// override logic throughout the different sub-renderers
@@ -333,8 +333,7 @@ export class WebglCharAtlas implements IDisposable {
this._workAttributeData.fg = fg;
this._workAttributeData.bg = bg;
// TODO: Use packed ext format
this._workAttributeData.extended.underlineStyle = ext;
this._workAttributeData.extended.ext = ext;
const invisible = !!this._workAttributeData.isInvisible();
if (invisible) {
@@ -423,6 +422,7 @@ export class WebglCharAtlas implements IDisposable {
this._tmpCtx.strokeStyle = this._tmpCtx.fillStyle;
this._tmpCtx.beginPath();
if (underline) {
console.log('ext', ext, this._workAttributeData.extended.underlineColor, this._workAttributeData.extended.underlineStyle);
const xLeft = padding;
const xRight = padding + this._config.scaledCharWidth;
const yMid = padding + this._config.scaledCharHeight - yOffset;
+1
View File
@@ -113,6 +113,7 @@ export interface IColor {
export type IColorRGB = [number, number, number];
export interface IExtendedAttrs {
ext: number;
underlineStyle: number;
underlineColor: number;
clone(): IExtendedAttrs;
+17 -11
View File
@@ -4,7 +4,7 @@
*/
import { IAttributeData, IColorRGB, IExtendedAttrs } from 'common/Types';
import { Attributes, FgFlags, BgFlags, UnderlineStyle } from 'common/buffer/Constants';
import { Attributes, FgFlags, BgFlags, UnderlineStyle, ExtFlags } from 'common/buffer/Constants';
export class AttributeData implements IAttributeData {
public static toColorRGB(value: number): IColorRGB {
@@ -127,26 +127,32 @@ 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; }
private _ext: number = 0;
public get ext(): number { return this._ext; }
public set ext(value: number) { this._ext = value; }
public get underlineStyle(): UnderlineStyle {
return (this._ext & ExtFlags.UNDERLINE_STYLE) >> 26;
}
public set underlineStyle(value: UnderlineStyle) {
this._underlineStyle = value;
this._ext &= ~ExtFlags.UNDERLINE_STYLE;
this._ext |= (value << 26) & ExtFlags.UNDERLINE_STYLE;
}
// underline color, -1 is empty (same as FG)
private _underlineColor: number = -1;
public get underlineColor(): number { return this._underlineColor; }
public get underlineColor(): number {
return this._ext & (Attributes.CM_MASK | Attributes.RGB_MASK);
}
public set underlineColor(value: number) {
this._underlineColor = value;
this._ext &= ~(Attributes.CM_MASK | Attributes.RGB_MASK);
this._ext |= value & (Attributes.CM_MASK | Attributes.RGB_MASK);
}
constructor(
underlineStyle: UnderlineStyle = UnderlineStyle.NONE,
underlineColor: number = -1
) {
this._underlineStyle = underlineStyle;
this._underlineColor = underlineColor;
this.underlineStyle = underlineStyle;
this.underlineColor = underlineColor;
}
public clone(): IExtendedAttrs {
+7
View File
@@ -130,6 +130,13 @@ export const enum BgFlags {
HAS_EXTENDED = 0x10000000
}
export const enum ExtFlags {
/**
* bit 27..32 (upper 3 unused)
*/
UNDERLINE_STYLE = 0x1C000000
}
export const enum UnderlineStyle {
NONE = 0,
SINGLE = 1,