module

Lipgloss

Constants

NBSP = '\u00A0'

Non-breaking space rune.

NO_TAB_CONVERSION = -1

NoTabConversion can be passed to TabWidth to disable tab replacement

OSC_BG_QUERY = "\e]11;?\a"
TAB_WIDTH_DEFAULT = 4

Tab width default

UnderlineCurly = Ansi::Style::UnderlineCurly
UnderlineDashed = Ansi::Style::UnderlineDashed
UnderlineDotted = Ansi::Style::UnderlineDotted
UnderlineDouble = Ansi::Style::UnderlineDouble
UnderlineNone = Ansi::Style::UnderlineNone

Underline style constants (re-exported from Ansi::Style)

UnderlineSingle = Ansi::Style::UnderlineSingle
VERSION = "2.0.0"

Class methods

alpha(color : Color | RGBAColor | Nil, alpha : Float64) : RGBAColor | Nil
ascii_border

ASCIIBorder returns a table border with ASCII characters.

background_color(input : IO = STDIN, output : IO = STDOUT) : Color
blend1d(steps : Int32, stops : Array(Color | RGBAColor | Nil)) : Array(Color) | Nil
blend1d(steps : Int32) : Array(Color) | Nil
blend1d(steps : Int32, *stops : Color | RGBAColor | Nil) : Array(Color) | Nil
blend2d(width : Int32, height : Int32, angle : Float64) : Array(Color) | Nil
blend2d(width : Int32, height : Int32, angle : Float64, *stops : Color | RGBAColor | Nil) : Array(Color) | Nil
block_border

BlockBorder returns a border that takes the whole block.

color(spec : String) : Color | NoColor
complementary(color : Color | RGBAColor | Nil) : RGBAColor | Nil
complete(profile : Colorprofile::Profile) : CompleteFunc

Complete returns a function that will return the appropriate color based on the given color profile.

Example usage: p = Colorprofile.detect(io, ENV.to_a) complete = Lipgloss.complete(p) color = complete.call( Lipgloss.color("1"), # ANSI Lipgloss.color("124"), # ANSI256 Lipgloss.color("#ff34ac") # TrueColor )

darken(color : Color | RGBAColor | Nil, percent : Float64) : RGBAColor | Nil
double_border

DoubleBorder returns a border comprised of two thin strokes.

enable_legacy_windows_ansi(file : IO) : Nil

EnableLegacyWindowsANSI enables support for ANSI color sequences in the Windows default console (cmd.exe and the PowerShell application). Note that this only works with Windows 10 and greater. Also note that Windows Terminal supports colors by default.

This is a no-op on non-Windows platforms.

fprint(io : IO, *args) : Tuple(Int32, Nil)
fprintf(io : IO, format : String, *args) : Tuple(Int32, Nil)
fprintln(io : IO, *args) : Tuple(Int32, Nil)
get_first_rune_as_string(str : String) : String

Gets the first UTF-8 rune from a string.

has_dark_background(input : IO = STDIN, output : IO = STDOUT) : Bool
has_dark_background=(has_dark_background : Bool)

Global setting for adaptive colors

has_dark_background?

Global setting for adaptive colors

height(str : String) : Int32

Measure height of rendered string (line count)

hidden_border

HiddenBorder returns a border that renders as a series of single-cell spaces. It's useful for cases when you want to remove a standard border but maintain layout positioning.

inner_half_block_border

InnerHalfBlockBorder returns a half-block border that sits inside the frame.

join_horizontal(pos : Position, blocks : Array(View)) : String
join_horizontal(pos : Position, blocks : Array(String)) : String
join_horizontal(pos : Float64, blocks : Array(View)) : String
join_horizontal(pos : Float64, blocks : Array(String)) : String
join_horizontal(pos : Position, *blocks : String) : String

Join strings horizontally with alignment

join_horizontal(pos : Position, *blocks : View) : String
join_horizontal(pos : Float64, *blocks : String) : String
join_horizontal(pos : Float64, *blocks : View) : String
join_vertical(pos : Position, blocks : Array(String)) : String
join_vertical(pos : Float64, blocks : Array(String)) : String
join_vertical(pos : Position, *blocks : String) : String

Join strings vertically with alignment

join_vertical(pos : Position, *blocks : View) : String
join_vertical(pos : Float64, *blocks : String) : String
join_vertical(pos : Float64, *blocks : View) : String
light_dark(is_dark : Bool) : LightDarkFunc

LightDark returns a function that selects between a light and dark color based on the given boolean. If is_dark is true, the returned function will pick the dark color; otherwise it will pick the light color.

lighten(color : Color | RGBAColor | Nil, percent : Float64) : RGBAColor | Nil
markdown_border

MarkdownBorder returns a table border in markdown style. Make sure to disable top and bottom border for the best result. This will ensure that the output is valid markdown.

new_canvas(width : Int32, height : Int32) : Canvas
new_compositor
new_compositor(*layers : Layer) : Compositor
new_layer(content : String) : Layer
new_layer(content : String, *layers : Layer) : Layer
new_range(start : Int32, finish : Int32, style : Style) : Range

Create a new style range (factory method matching Go lipgloss)

new_renderer(_io : IO, *_opts) : Renderer
new_style

Create a new style (convenience)

normal_border

NormalBorder returns a standard-type border with a normal weight and 90 degree corners.

outer_half_block_border

OuterHalfBlockBorder returns a half-block border that sits outside the frame.

parse_hex?(hex : String) : RGBAColor | Nil
place(width : Int32, height : Int32, h_pos : Position, v_pos : Position, content : String, *opts : WhitespaceOption) : String
place(width : Int32, height : Int32, h_pos : Float64, v_pos : Float64, content : String, *opts : WhitespaceOption) : String
place_horizontal(width : Int32, pos : Position, content : String, *opts : WhitespaceOption) : String
place_horizontal(width : Int32, pos : Float64, content : String, *opts : WhitespaceOption) : String
place_vertical(height : Int32, pos : Position, content : String, *opts : WhitespaceOption) : String
place_vertical(height : Int32, pos : Float64, content : String, *opts : WhitespaceOption) : String
printf(format : String, *args) : Tuple(Int32, Nil)
println(*args) : Tuple(Int32, Nil)
rounded_border

RoundedBorder returns a border with rounded corners.

size(str : String) : Tuple(Int32, Int32)

Get both width and height

sprint(*args) : String
sprintf(format : String, *args) : String
sprintln(*args) : String
style_ranges(str : String, ranges : Array(Range)) : String
style_ranges(str : String, *ranges : Range) : String

Apply styling to ranges in a string (variadic version matching Go lipgloss)

style_runes(str : String, indices : Array(Int32), matched : Style, unmatched : Style) : String

Apply styles to specific rune (grapheme) indices.

thick_border

ThickBorder returns a border that's thicker than the one returned by NormalBorder.

width(str : String) : Int32

Measure width of rendered string (max line width)

with_whitespace_chars(chars : String) : WhitespaceOption
with_whitespace_style(style : Style) : WhitespaceOption
wrap(s : String, width : Int32, breakpoints : String = "") : String

Wrap wraps the given string to the given width, preserving ANSI styles and links.

writer
writer=(w : IO | Colorprofile::Writer)

Nested types