ReadonlybgBackground 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.
Static ReadonlyemptySets background color.
basic, indexed or (packed) RGB color
Sets foreground color.
basic, indexed or (packed) RGB color
Formats a string with this style applied.
Check if a bit is set at the specified position
The bit position (0-63)
true if the bit is set, false otherwise
Returns a hash of the attributes. This is useful for comparing attributes.
Returns the ANSI SGR (Select Graphic Rendition) string representation of the
style.
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
StaticfromCreate a Style from an instance of Attributes or an object of attributes properties.
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]
An immutable class for styling text.
Example