Lyricdev
GitHub

struct Style

pub struct Style :: [Equatable, Debug]

Conforms to Equatable, Debug.

A set of attributes to put on a text: colors and SGR flags, all off by default.

Fields

pub fg: ?Color = null
pub bg: ?Color = null
pub bold: bool = false
pub dim: bool = false
pub italic: bool = false
pub underline: bool = false
pub inverse: bool = false
pub strike: bool = false

Methods

pub fn isPlain(): bool

Returns whether the style sets no color and no attribute.

pub fn sgr(): string

Returns the SGR sequence that turns the style on.

Returns an empty string for a plain style.

pub fn apply(text: string): string

Returns the text wrapped in the style's sequence and the reset.

Returns the text unchanged where the style is plain or colorsEnabled says no.

pub fn force(text: string): string

Returns the text wrapped in the style's sequence and the reset, whatever the terminal is.

Returns the text unchanged only where the style is plain.