ANSI
:= []
Add styles to a string.
Add color styles to a string and then reset to default.
parse_raw_stdin : List(U8) -> Input
input_to_str : Input -> Str
symbol_to_str : Symbol -> Str
upper_to_str : Letter -> Str
lower_to_str : Letter -> Str
Request the text-area size using the xterm window-operation query. Write and flush this string without adding a newline. Not every terminal supports the query; use a read deadline and a fallback size.
parse_screen_size : List(U8) -> Try(ScreenSize, [InvalidScreenSize])
Parse one complete terminal size report, such as ESC[8;24;80t. Accepts ESC[ and the single-byte CSI (0x9B). Both dimensions must be decimal integers from 1 through 65535. Rejects incomplete replies, trailing input, pixel reports and malformed or out-of-range dimensions.
query_screen_size! : { write! : Str => Try({}, write_err), read! : () => Try(List(U8), read_err) } => Try({ size : ScreenSize, input : List(U8) }, [WriteFailed(write_err), ReadFailed(read_err, List(U8)), NoResponse(List(U8)), InvalidResponse(List(U8)), InputLimitExceeded(List(U8))])
Send a size request and read its response using your platform's I/O.
write! must flush before returning; read! must enforce a deadline
for the whole query, because unsupported terminals may never reply.
Reads may split the response at any byte. The result's input contains
all bytes before and after the report, in order, for your input handler.
An empty read returns NoResponse. Invalid reports and a 4096-byte input
limit stop the query. Read/response errors retain all received bytes;
write errors occur before any input is read. Terminal mode is unchanged.
See the terminal-size guide
for terminal support, callback contracts and fallback handling.
parse_cursor : List(U8) -> CursorPosition
update_cursor : { cursor : CursorPosition, screen : ScreenSize }, Arrow -> { cursor : CursorPosition, screen : ScreenSize }
draw_screen : { cursor : CursorPosition, screen : ScreenSize }, List(DrawFn) -> Str
Loop through each pixel in the screen and build up a single string to write to stdout.
draw_cursor : { fg : Color, bg : Color, char : Str, styles : List(Style) } -> DrawFn
Draw one extended grapheme cluster per logical cell. Combining marks and emoji sequences stay intact. This does not calculate terminal display widths: wide characters may occupy more than one physical column.
Escape
:= [
Reset,
Control(Control),
]
Symbol
:= [
ExclamationMark,
QuotationMark,
NumberSign,
DollarSign,
PercentSign,
Ampersand,
Apostrophe,
RoundOpenBracket,
RoundCloseBracket,
Asterisk,
PlusSign,
Comma,
Hyphen,
FullStop,
ForwardSlash,
Colon,
SemiColon,
LessThanSign,
EqualsSign,
GreaterThanSign,
QuestionMark,
AtSign,
SquareOpenBracket,
Backslash,
SquareCloseBracket,
Caret,
Underscore,
GraveAccent,
CurlyOpenBrace,
VerticalBar,
CurlyCloseBrace,
Tilde,
]
Ctrl
:= [Space, A, B, C, D, E, F, G, H, I, J, K, L, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, BackSlash, SquareCloseBracket, Caret, Underscore]
Action
:= [Escape, Enter, Space, Delete]
Arrow
:= [Up, Down, Left, Right]
Number
:= [N0, N1, N2, N3, N4, N5, N6, N7, N8, N9]
Letter
:= [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z]
Input
:= [
Ctrl(Ctrl),
Action(Action),
Arrow(Arrow),
Symbol(Symbol),
Number(Number),
Upper(Letter),
Lower(Letter),
Unsupported(List(U8)),
]
ScreenSize : { width : U16, height : U16 }
Terminal text-area dimensions in character cells, not pixels.
CursorPosition : { row : U16, col : U16 }