CRT::Ansi::Style::Text
An array of styled text spans for rich text rendering.
Build from an array of parts — a mini-DSL for styled text:
bold = Style.new(bold: true)
red = Style.new(fg: Color.indexed(1))
text = Style::Text.new([
"plain ", bold, "bold ", red, "bold+red",
Style::POP, " bold again",
Style::RESET, " back to default",
] of Style::Text::Part)
Part types:
String— text content, styled by the current stack topStyle— merge onto style stack (additive)Style::Char— emit its char with its own styleStyle::Text— splice its spans in verbatimPOP— pop the style stackRESET— clear the stack back to default
Constructors
new
SourceInstance methods
empty?
Sourcespans
Sourceto_s
Returns a nicely readable and concise string representation of this object, typically intended for users.
This method should usually not be overridden. It delegates to
#to_s(IO) which can be overridden for custom implementations.
Also see #inspect.