text.bend checks
raw source on the hub · import bend-kit-tty@0.1.0.0/text.bend as Text
Pure terminal text: ANSI SGR styling and Unicode 17 display width.
3 imports
import Base import 0x6c784a08486e2e02415e89c5249e9e8a/unicode.bend as Unicode import ./width.bend as W
Definitions
def style source · line 7 · raw
@enabled:Bool -> @code:U32 -> @text:String -> String
Wrap text in one numeric SGR code and a reset when enabled; otherwise return it unchanged.
def vs16 source · line 14 · raw
@s:String -> Bool
def cluster source · line 22 · raw
@g:String -> U32
A grapheme cluster takes its first code point's columns (W.w); VS16 makes a narrow base an emoji, 2 wide.
def width.go source · line 30 · raw
@gs:List<&2, String> -> @+acc:U32 -> U32
def width source · line 39 · raw
@text:String -> U32
Display columns: East Asian Wide and Fullwidth clusters are 2, marks and controls 0, Ambiguous 1. Escape sequences are not stripped: style()'s output is wider than what the terminal shows.
def pad_right source · line 43 · raw
@+text:String -> @+cols:U32 -> String
Append spaces until text occupies at least cols display columns.