Optionalattributes: numberOptionalbackground: null | numberOptionalforeground: null | numberOptionalunderline: null | numberReadonlybgBackground color
Either an ANSI indexed color (0-255) or a packed RGB.
ReadonlyfgForeground color
Either an ANSI indexed color (0-255) or a packed RGB.
ReadonlyulUnderline color
Either an ANSI indexed color (0-255) or a packed RGB.
ReadonlyvalueAttributes
A bitset representening the set attributes.
Sets background color.
basic, indexed or (packed) RGB color
Sets foreground color.
basic, indexed or (packed) RGB color
Check if a bit is set at the specified position
The bit position (0-63)
true if the bit is set, false otherwise
Set a bit at the specified position
The bit position (0-63)
Optionalbg: numberbackground color
Optionalfg: numberforeground color
Optionalul: numberunderline color
A new Attributable instance with the bit set
Toggle a bit at the specified position
The bit position (0-63)
A new Attributable instance with the bit toggled
Returns a hash of the attributes. This is useful for comparing attributes.
Optionalradix: numberSets underline color.
basic, indexed or (packed) RGB color
Unset a bit at the specified position
The bit position (0-63)
Optionalbg: numberbackground color
Optionalfg: numberforeground color
Optionalul: numberunderline color
A new Attributable instance with the bit unset
ProtectedwithReturn a new Attributable instance with the given parameters.
Optionalattributes: numberNext value of the attributable
Optionalbackground: null | numberNext background color
Optionalforeground: null | numberNext foreground color
Optionalunderline: null | numberNext underline color
function with(
attributes?: number,
background?: ColorAttribute | null,
foreground?: ColorAttribute | null,
underline?: ColorAttribute | null,
) {
return new Attributes(
attributes ?? this.value,
background === null ? null : background || this.bg,
foreground === null ? null : foreground || this.fg,
underline === null ? null : underline || this.ul,
);
}
StaticattributeConverts a color to an SGR attribute string.
Color vector [0-1]
SGR attribute string, e.g., 255:128:64
StaticpackPacks an RGB color into a packed RGB value.
Color vector [0-1]
StaticunpackUnpacks a packed RGB value into an RGB color.
packed RGB value
Color vector [0-1]
Attributes
A performant bitset representation to handle SGR attributes.
Example