module

Smith::UI::LineUtil

Line-level helpers shared by everything that lays text out.

Constants

EMPTY = [] of Span

Class methods

line(text : String, style : Style = Style::NONE) : StyledLine

A styled line from plain text.

Source
plain(line : StyledLine) : String
Source
render(line : StyledLine, io : IO, color : Bool = true) : Nil
Source
to_ansi(line : StyledLine, color : Bool = true) : String
Source
truncate(line : StyledLine, width : Int32, ellipsis : String | Nil = nil) : StyledLine

Cuts a line to width columns, optionally with an ellipsis. Never splits a double-width character in half: if it does not fit, the cut happens one column earlier.

Source
width(line : StyledLine) : Int32
Source
wrap(line : StyledLine, width : Int32) : Array(StyledLine)

Greedy word wrap that keeps styles intact. Words longer than the width are hard-broken; spaces at a wrap point are dropped rather than trailing.

Source