class

Term2::Style

Inherits Reference < Object

Style is the core styling primitive - a complete Lipgloss port

Constants

WRAP_CACHE_MAX = 256

Constructors

new_style

Create a new style (factory method like Lipgloss)

Source

Class methods

join_horizontal(pos : Position, strs : Array(String)) : String
Source
join_horizontal(pos : Float64, strs : Array(String)) : String
Source
join_horizontal(pos : Position, *strs : String) : String

JoinHorizontal is a utility function for horizontally joining two potentially multi-lined strings along a vertical axis.

pos: Vertical alignment (Top, Bottom, Center)

Source
join_horizontal(pos : Float64, *strs : String) : String
Source
join_vertical(pos : Position, strs : Array(String)) : String
Source
join_vertical(pos : Float64, strs : Array(String)) : String
Source
join_vertical(pos : Position, *strs : String) : String

JoinVertical is a utility function for vertically joining two potentially multi-lined strings along a horizontal axis.

pos: Horizontal alignment (Left, Right, Center)

Source
join_vertical(pos : Float64, *strs : String) : String
Source

Instance methods

align(h : Position, v : Position) : Style

Alignment - two arguments set horizontal and vertical

Source
align(p : Position) : Style

Alignment - single argument sets horizontal

Source
align_horizontal(p : Position) : Style
Source
align_horizontal_value
Source
align_value
Source
align_vertical(p : Position) : Style
Source
align_vertical_value
Source
background(c : Color | AdaptiveColor | CompleteColor) : Style
Source
background(hex : String) : Style
Source
background_color
Source
bg_hex(hex : String) : Style
Source
bg_indexed(idx : Int32) : Style

Compatibility helpers for older example code.

Source
black
Source
blue
Source
bold(v : Bool = true) : Style

Text formatting

Source
bold=(value : Bool) : Bool
Source
bold?

Crystal-idiomatic boolean getters

Source
border(b : Border) : Style

Border [FIX] Explicit overload for single argument to satisfy compiler

Source
border(b : Border, *sides : Bool) : Style
Source
border_background(c : Color | AdaptiveColor) : Style
Source
border_bottom(v : Bool = true) : Style
Source
border_bottom_background(c : Color | AdaptiveColor) : Style
Source
border_bottom_foreground(c : Color | AdaptiveColor) : Style
Source
border_foreground(c : Color | AdaptiveColor) : Style
Source
border_left(v : Bool = true) : Style
Source
border_left_background(c : Color | AdaptiveColor) : Style
Source
border_left_foreground(c : Color | AdaptiveColor) : Style
Source
border_right(v : Bool = true) : Style
Source
border_right_background(c : Color | AdaptiveColor) : Style
Source
border_right_foreground(c : Color | AdaptiveColor) : Style
Source
border_style(b : Border) : Style
Source
border_top(v : Bool = true) : Style
Source
border_top_background(c : Color | AdaptiveColor) : Style
Source
border_top_foreground(c : Color | AdaptiveColor) : Style
Source
bright_blue
Source
bright_cyan
Source
bright_gray
Source
bright_green
Source
bright_magenta
Source
bright_red
Source
bright_yellow
Source
color_whitespace(v : Bool = true) : Style
Source
color_whitespace?
Source
copy
Source
cyan
Source
dark_gray
Source
faint(v : Bool = true) : Style
Source
faint=(value : Bool) : Bool
Source
faint?
Source
fg_hex(hex : String) : Style
Source
fg_indexed(idx : Int32) : Style

Compatibility helpers for older example code.

Source
foreground(c : Color | AdaptiveColor | CompleteColor) : Style

Colors

Source
foreground(hex : String) : Style
Source
foreground_color
Source
get_align
Source
get_align_horizontal
Source
get_align_vertical
Source
get_background

DEPRECATED Use #background_color instead

Source
get_bold

Aliases for backwards compatibility

Source
get_bool(prop : Props) : Bool
Source
get_border
Source
get_border_bottom
Source
get_border_bottom_size
Source
get_border_left
Source
get_border_left_size
Source
get_border_right
Source
get_border_right_size
Source
get_border_style
Source
get_border_top
Source
get_border_top_size
Source
get_color_whitespace

DEPRECATED Use #color_whitespace? instead

Source
get_faint
Source
get_foreground

DEPRECATED Use #foreground_color instead

Source
get_frame_size
Source
get_height
Source
get_horizontal_border_size
Source
get_horizontal_frame_size

Frame size calculations

Source
get_horizontal_margins
Source
get_horizontal_padding
Source
get_inline
Source
get_italic

DEPRECATED Use #italic? instead

Source
get_margin
Source
get_margin_bottom
Source
get_margin_left
Source
get_margin_right
Source
get_margin_top
Source
get_max_height
Source
get_max_width
Source
get_padding
Source
get_padding_bottom
Source
get_padding_left
Source
get_padding_right
Source
get_padding_top
Source
get_reverse
Source
get_strikethrough
Source
get_strikethrough_spaces

DEPRECATED Use #strikethrough_spaces? instead

Source
get_tab_width
Source
get_transform
Source
get_underline

DEPRECATED Use #underline? instead

Source
get_underline_spaces
Source
get_vertical_border_size
Source
get_vertical_frame_size
Source
get_vertical_margins
Source
get_vertical_padding
Source
get_width

Backwards compatibility aliases

Source
green
Source
height(h : Int32) : Style
Source
height_value
Source
inherit(other : Style) : Style

Inherit overlays the style in the argument onto this style Only unset rules on the receiver are inherited. Margins, padding, and underlying string values are not inherited.

Source
inline(v : Bool = true) : Style

Other

Source
is_set?(prop : Props) : Bool
Source
italic(v : Bool = true) : Style
Source
italic=(value : Bool) : Bool
Source
italic?
Source
magenta
Source
margin(top : Int32, right : Int32, bottom : Int32, left : Int32) : Style
Source
margin(top : Int32, horizontal : Int32, bottom : Int32) : Style
Source
margin(vertical : Int32, horizontal : Int32) : Style
Source
margin(all : Int32) : Style

Margin - CSS shorthand style

Source
margin
Source
margin_background(c : Color | AdaptiveColor) : Style
Source
margin_bottom(i : Int32) : Style
Source
margin_left(i : Int32) : Style
Source
margin_right(i : Int32) : Style
Source
margin_top(i : Int32) : Style
Source
max_height(h : Int32) : Style
Source
max_height_value
Source
max_width(w : Int32) : Style
Source
max_width_value
Source
merge(other : Style) : Style

Merge another style into this one Properties that are set in the other style will override this style's properties

Source
on_black
Source
on_blue
Source
on_bright_blue
Source
on_bright_cyan
Source
on_bright_gray
Source
on_bright_green
Source
on_bright_magenta
Source
on_bright_red
Source
on_bright_yellow
Source
on_cyan
Source
on_dark_gray
Source
on_green
Source
on_magenta
Source
on_red
Source
on_white
Source
on_yellow
Source
padding(top : Int32, right : Int32, bottom : Int32, left : Int32) : Style
Source
padding(top : Int32, horizontal : Int32, bottom : Int32) : Style
Source
padding(vertical : Int32, horizontal : Int32) : Style
Source
padding(all : Int32) : Style

Padding - CSS shorthand style

Source
padding
Source
padding_bottom(i : Int32) : Style
Source
padding_left(i : Int32) : Style
Source
padding_right(i : Int32) : Style
Source
padding_top(i : Int32) : Style
Source
render(strs : Array(String)) : String
Source
render
Source
render(*strs : String) : String

Render applies the style to the given string(s)

Source
renderer(r : StyleRenderer) : Style
Source
reverse(v : Bool = true) : Style
Source
reverse=(value : Bool) : Bool
Source
reverse?
Source
set_string(*strs : String) : Style

SetString sets the underlying string value for the style

Source
strikethrough(v : Bool = true) : Style
Source
strikethrough=(value : Bool) : Bool
Source
strikethrough?
Source
strikethrough_spaces(v : Bool = true) : Style
Source
strikethrough_spaces?
Source
string=(str : String) : Style
Source
tab_width(n : Int32) : Style
Source
to_s

String implements the Stringer interface

Source
transform(fn : Proc(String, String)) : Style
Source
underline(v : Bool = true) : Style
Source
underline=(value : Bool) : Bool
Source
underline?
Source
underline_spaces(v : Bool = true) : Style
Source
underline_spaces?
Source
unset_align
Source
unset_align_horizontal
Source
unset_align_vertical
Source
unset_background
Source
unset_bold
Source
unset_border_background
Source
unset_border_bottom
Source
unset_border_foreground
Source
unset_border_left
Source
unset_border_right
Source
unset_border_style
Source
unset_border_top
Source
unset_color_whitespace
Source
unset_faint
Source
unset_foreground
Source
unset_height
Source
unset_inline
Source
unset_italic
Source
unset_margin_background
Source
unset_margin_bottom
Source
unset_margin_left
Source
unset_margin_right
Source
unset_margin_top
Source
unset_margins
Source
unset_max_height
Source
unset_max_width
Source
unset_padding
Source
unset_padding_bottom
Source
unset_padding_left
Source
unset_padding_right
Source
unset_padding_top
Source
unset_reverse
Source
unset_strikethrough
Source
unset_strikethrough_spaces
Source
unset_string
Source
unset_tab_width
Source
unset_transform
Source
unset_underline
Source
unset_underline_spaces
Source
unset_width
Source
value

Value returns the raw, unformatted string value

Source
white
Source
width(w : Int32) : Style

Dimensions

Source
width_value

Crystal-idiomatic property getters

Source
yellow
Source

Nested types