class Foundation::Style

Overview

Build a Select Graphic Rendition (SGR) escape sequence by accumulating parameters. Mutating is chainable, each method appends and returns self.

Defined in:

foundation/sgr.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new #

Create an empty builder with no parameters set.


[View source]

Instance Method Detail

def background(color : SGRColor) : self #

Appends a background color resolved to its SGR kind (eg basic/indexed/rgb/default).


[View source]
def background_basic(index : UInt8) : self #

Set a basic bg color by index 0..15 (SGR 40-37 / 100-107 bright).

Raises if index > 15


[View source]
def background_indexed(index : UInt8) : self #

Sets a 256-color bg by palette index (SGR 48;5;index)


[View source]
def background_rgb(r : UInt8, g : UInt8, b : UInt8) : self #

Sets a truecolor bg (SGR 48;2;r;g;b)


[View source]
def blink : self #

Enable blink (SGR 5)


[View source]
def bold : self #

Enable bold (SGR 1)


[View source]
def default_background : self #

Resets the bg to terminal default (SGR 49)


[View source]
def default_foreground : self #

Resets fg to terminal default (SGR 39)


[View source]
def faint : self #

Enable faint/dim (SGR 2)


[View source]
def foreground(color : SGRColor) : self #

Appends a foreground color resolved to its SGR kind (eg basic/indexed/rgb/default).


[View source]
def foreground_basic(index : UInt8) : self #

Set a basic fg color by index 0..15 (SGR 30-37 / 90-97 bright).

Raises if index > 15


[View source]
def foreground_indexed(index : UInt8) : self #

Sets a 256-color fg by palette index (SGR 38;5;index)


[View source]
def foreground_rgb(r : UInt8, g : UInt8, b : UInt8) : self #

Sets a truecolor fg (SGR 38;2;r;g;b)


[View source]
def italic : self #

Enable italic (SGR 3)


[View source]
def raw(param : String) : self #

Appends a raw SGR parameter as-is, for params that the typed setters don't model.


[View source]
def reset : self #

Resets all attributes (SGR 0)


[View source]
def reverse : self #

Enable reverse which swaps fg and bg (SGR 7)


[View source]
def strikethrough : self #

Enable strikethrough (SGR 9)


[View source]
def to_s(io : IO) : Nil #

Renders the accumulated params as a CSI ... m sequence. Or nothing if no params are set.


[View source]
def underline : self #

Enable single underline (SGR 4)


[View source]
def underline_style(style : Underline) : self #

Enable underline of given substyle (SGR 4:n)


[View source]