struct

Smith::UI::Style

Inherits Struct < Value < Object

The smallest unit of styled terminal text. Styles are merged while a line is assembled, so markdown rendering can layer emphasis on top of a block's base style without knowing about it.

Constants

NONE = Style.new

Constructors

new(fg : Int32 | Nil = nil, bold : Bool = false, dim : Bool = false, italic : Bool = false, underline : Bool = false, invert : Bool = false)
Source

Class methods

char_width(char : Char) : Int32
Source
display_width(text : String) : Int32

Columns a string occupies in the terminal. ASCII is 1; CJK, fullwidth forms and most emoji are 2; combining marks and zero-width characters are 0. An approximation — but the same one most terminals make.

Source

Instance methods

ansi
Source
bold=(bold : Bool)
Source
bold?
Source
dim=(dim : Bool)
Source
dim?
Source
fg

256-colour palette index; nil keeps the terminal default.

Source
fg=(fg : Int32 | Nil)

256-colour palette index; nil keeps the terminal default.

Source
invert=(invert : Bool)
Source
invert?
Source
italic=(italic : Bool)
Source
italic?
Source
merge(other : Style) : Style

other wins wherever it is set; used to layer inline markdown styles on top of the block style they appear in.

Source
plain?
Source
underline=(underline : Bool)
Source
underline?
Source