Skip to content

Style

Reusable terminal style settings.

Calling a Style applies its saved settings. Supplied options override saved colors or enable additional attributes; omitted options retain saved settings, and :INHERIT: clears them.

Inherits from: Func

Constructor

Style ...options

Creates a reusable style.

To style text as well, use text.

Parameters

NameTypeDescription
...options StyleOptions The style options.

Example

let warning = term.Style fg: :YELLOW: bold: true

Methods

(call) ...options -> Style overload 1 of 2

Applies or derives the saved style.

Also accepts the style options, which override what is saved.

Parameters

NameTypeDescription
...options StyleOptions

Returns

Text when positional arguments are given, otherwise a derived Style.

Example

let warning = term.Style fg: :YELLOW: bold: true
let urgent = warning fg: :RED: underline: true
let uncolored = urgent fg: :INHERIT:

echo $warning("Warning")
echo $urgent("Failure")
echo $uncolored("Notice")

(call) value ...args -> Text overload 2 of 2

Applies or derives the saved style.

Also accepts the style options, which override what is saved.

Parameters

NameTypeDescription
value Value
...args {*Value, ...StyleOptions}

Returns

Text when positional arguments are given, otherwise a derived Style.

Example

let warning = term.Style fg: :YELLOW: bold: true
let urgent = warning fg: :RED: underline: true
let uncolored = urgent fg: :INHERIT:

echo $warning("Warning")
echo $urgent("Failure")
echo $uncolored("Notice")