Skip to content
FutureBlitz

    Install

    Import std.term.style

    Style

    std.term.style

    struct

    Public Struct Style Implements Hashable, Printable

    How text looks: its Foreground color, the Background color behind it, and its Attributes. Its zero is plain text, as the terminal shows it, and Style(TermColor.Red).Bold() is bold red.

    Examples

    Local warning = Style(TermColor.Yellow).Bold()
    Expect(warning.Apply("careful", ColorLevel.NONE) == "careful")
    Local shown = warning.Apply("careful", ColorLevel.TRUE_COLOR)
    Expect(shown != "careful" && StripStyles(shown) == "careful")
    Expect(VisibleWidth(shown) == 7)

    std/term/style.fb, line 313

    • Public Field Foreground: TermColor field #

      Its text's color.

    • Public Field Background: TermColor field #

      The color behind its text.

    • Public Field Attributes: TextAttributes field #

      Its attributes, like BOLD, which combine.

    • Public Property IsPlain: Bool property #

      Whether it's plain text, as the terminal shows it.

    • Public Method On(background: TermColor): Style method #

      A copy with background behind the text.

    • Public Method With(attributes: TextAttributes): Style method #

      A copy with attributes too.

    • Public Method Bold(): Style method #

      A copy that's bold too.

    • Public Method Dim(): Style method #

      A copy that's dim too.

    • Public Method Italic(): Style method #

      A copy that's italic too.

    • Public Method Underline(): Style method #

      A copy that's underlined too.

    • Public Method Reverse(): Style method #

      A copy with its colors swapped too.

    • Public Method Hidden(): Style method #

      A copy that's hidden too.

    • Public Method Strikethrough(): Style method #

      A copy that's struck through too.

    • Public Method Over(under: Style): Style method #

      This style over under: its own colors, and under's where it has the terminal's NORMAL ones, and both's attributes, as a list's selected line is drawn over its own style.

    • Public Method Codes(level: ColorLevel): String method #

      The escape code that starts it, from plain text, as a terminal of level's colors shows it, like "\e[0;1;31m", or "" where level is NONE. A plain style is "\e[0m".

    • Public Method Apply(text: String, level: ColorLevel): String method #

      text as this style shows it on a terminal of level's colors: between the codes that start it and the one that ends it, or alone where level is NONE or the style is plain.

    • Public Method ToString(): String method #

      Like "bold red on blue", or "plain".

    Report an issue with this page or with FutureBlitz on GitHub.