struct TermBuf::Style

Overview

Everything about a cell other than the character in it.

Styles are values, so they compare and hash by content. StyleTable interns them, which is what lets a Cell carry a four byte id instead of this whole struct.

Defined in:

termbuf/core/style.cr

Constant Summary

DEFAULT = new

The style a freshly cleared terminal is in.

Constructors

Instance Method Summary

Constructor Detail

def self.new(foreground : Color = Color.default, background : Color = Color.default, underline_color : Color = Color.default, attributes : Attributes = Attributes::None, underline : Underline = Underline::None, link : UInt32 = 0_u32) #

[View source]

Instance Method Detail

def attributes : Attributes #

Everything a cell can be at once.


[View source]
def background : Color #

Cell colour behind the text.


[View source]
def bg(color : Color) : Style #

A copy with a different background.


[View source]
def blink(rapid : Bool = false) : Style #

A copy that blinks, slowly unless rapid.


[View source]
def bold : Style #

A copy with the bold attribute set.


[View source]
def conceal : Style #

A copy the terminal renders as blanks.


[View source]
def copy_with(foreground : Color = @foreground, background : Color = @background, underline_color : Color = @underline_color, attributes : Attributes = @attributes, underline : Underline = @underline, link : UInt32 = @link) : Style #

Returns a copy with the named fields replaced.


[View source]
def default? : Bool #

Whether this is the untouched style, which needs no escape sequence.


[View source]
def faint : Style #

A copy with the faint attribute set.


[View source]
def fg(color : Color) : Style #

A copy with a different text colour.


[View source]
def foreground : Color #

Text colour.


[View source]
def has?(flags : Attributes) : Bool #

Whether every attribute in flags is set.


[View source]
def ink? : Bool #

Whether the cell paints anything other than its background. A cell that does not is interchangeable with a blank of the same background, which is what lets the painter reach for an erase instead of writing spaces.


[View source]
def italic : Style #

A copy with the italic attribute set.


[View source]
def link : UInt32 #

OSC 8 hyperlink id, or zero for no link. Populated once link support lands; the buffer carries it through in the meantime.


[View source]
def linked(id : UInt32) : Style #

A copy carrying OSC 8 link id. Zero means no link.


[View source]
def reverse : Style #

A copy with foreground and background swapped by the terminal.


[View source]
def strike : Style #

A copy with the strike-through attribute set.


[View source]
def to_s(io : IO) : Nil #
Description copied from struct Struct

Same as #inspect(io).


[View source]
def underline : Underline #

Which of the underline styles, if any.


[View source]
def underline_color : Color #

Colour of the underline, when the terminal supports colouring it separately from the text.


[View source]
def underlined(style : Underline = Underline::Single, color : Color = @underline_color) : Style #

A copy carrying an underline. Terminals without ExtendedUnderline render every style as a plain one, and without UnderlineColor ignore color.


[View source]
def with(flags : Attributes) : Style #

Returns a copy with flags added.


[View source]
def without(flags : Attributes) : Style #

Returns a copy with flags removed.


[View source]