An immutable representation of an ANSI style. Used by Terminal and Block to represent the styles in use for text to be printed. If a Style object is created with the same properties as a formerly seen Style object, the same object will be returned.

For example:

const a = new Style({ bold: true })
const b = new Style({ bold: true })
assert.equal(a, b) // passes

This optimization cuts down considerably on object creation, because a Style is created for each styled character written to the Terminal buffer. It also means that Style objects can be compared directly with === to test for equivalence.

Constructors

Accessors

  • get ansi(): string
  • corresponding ANSI code sequence for this style

    Returns string

  • get isReset(): boolean
  • True if this style is a full reset of all properties.

    Returns boolean

Methods

  • Return just the CSS for the styles. Href is not relevant.

    Returns string

  • Return a new Style with this one plus the updated properties.

    If a string is provided, must be a valid set of style and OSC hyperlink ANSI code, though unrecognized parameters within that code will be ignored rather than throwing an error.

    Parameters

    Returns Style

  • Wrap the input string in the appropriate HTML for this style

    Parameters

    • s: string

    Returns string

  • If the input string is a sequence of only ANSI style and OSC href codes, returns the array of codes and their parameters. Otherwise, returns false.

    Parameters

    • s: string

    Returns null | [string, string][]