Phosphor::Style
Visual style for a terminal cell: foreground/background colors and text attributes.
Style is an immutable value type. Every attribute method returns a new Style with
that attribute applied — chain them freely: Style.new.fg(my_color).bold.italic.
Read boolean attributes back via ? predicates (bold?, italic?, etc.).
Style.default is the zero value — no attributes set, renders as the terminal default.
ANSI escape generation is deferred to Phase 15 (buf.set_string will call it there).
Constructors
Instance methods
Returns a copy with the background color set to color. Accepts an
AdaptiveColor as well as a plain Color — either way, the value is
stored unresolved; Buffer#set_string resolves it at render time.
Returns a copy with blinking text applied. Use sparingly — many users find it distracting.
Downsamples fg/bg to what profile actually supports, using
Euclidean distance in RGB space to find the nearest representable
color. Call after #resolve — fg/bg must already be concrete
Color values (never AdaptiveColor) by this point; see
Buffer#set_string for the full pipeline.
ColorProfile::NoColor strips every attribute, not just fg/bg —
that profile has no ANSI output at all, so nothing else matters either.
Returns a copy with the foreground color set to color. Accepts an
AdaptiveColor as well as a plain Color — either way, the value is
stored unresolved; Buffer#set_string resolves it at render time.
Merges two styles. other wins on any attribute it explicitly sets;
unset attributes in other fall back to self.
For Bool attributes "set" means true; for Color attributes "set" means non-nil.
Returns a copy with any AdaptiveColor in fg/bg resolved to a
concrete Color, using dark_background to pick the right half of
the pair. A plain Color (or nil) passes through unchanged.
Called once, by Buffer#set_string, at the moment a Style is
actually written into a Cell — Style itself stays
environment-independent until then.
Returns the SGR (Select Graphic Rendition) parameter codes for this
style, ready to join with ; and wrap in \e[...m — e.g.
["1", "38;5;208"] for bold with an indexed foreground color. Empty
if nothing is set, meaning the terminal's own defaults apply.
fg/bg must already be resolved and downsampled to a concrete
Color (or nil) by this point — see Buffer#set_string, which
calls #resolve then #downsample before a Style ever reaches a
Cell. Color::Default and nil both mean "no explicit color" and
emit nothing.