Lynxer

Documentation

Terminal UI Module

The tui module provides terminal UI functionality using Rust's ratatui and crossterm crates.

How it renders

The backend never takes over the terminal for a plain rendering call. Each rendering function draws a ratatui widget into an offscreen buffer and prints the result:

setWidth(width) pins the render width (default 80) and setSoftWrap controls wrapping. panel*, rule*, table*, tree*, layout*, progress*, status* and live* render the state that was previously stored, so they reflect the data rather than a fixed template. Progress and live updates redraw in place on a TTY; when output is redirected they print deterministic snapshots. Status updates remain ordinary output.

markdown renders CommonMark through pulldown-cmark (headings, emphasis, inline and fenced code, ordered/unordered/task lists, block quotes, rules, links and simple tables), and printSyntax highlights code with syntect using Sublime syntax definitions. The highlighted syntax and theme sets are embedded in the module, so nothing is read from disk and no system oniguruma is required (syntect uses the pure-Rust fancy-regex backend). theme chooses a highlighting theme, themeNames lists them and themeName reports the active one.

Handles

table*, tree*, layout*, progress*, status* and live* return integer handles into backend registries. A handle stays valid for the run; progress, status and live free theirs on stop. An invalid handle returns -1.

Prompts

ask, askPassword, askInt, askFloat, askDefault, confirm and confirmDefault read one line from stdin. At end-of-file — a closed pipe, a redirected file, CI — they return the documented default instead of blocking, so a script is safe to run non-interactively. askPassword disables echo only when stdin is a terminal. askInt/askFloat return 0/0.0 for unparsable input.

Styles and markup

printText interprets [tag]…[/tag] markup when markup is enabled, and markupEscape escapes a literal [. A style is a subset of Rich's syntax: modifiers (bold, dim, italic, underline, blink, reverse, hidden, strike) and colors (red, bright blue, white on blue, …). styleValid returns false when a string contains an unknown token.

Functions

Existence and Version

Printing

Panels and Rules

Tables

Trees

Layouts

Progress, Status, Live

Console Configuration

Markup and Styles

Prompts

TUI Mode

Widgets

Terminal Control

Input

Selection Prompts

Screen and Themes

Interactive Menu, SVG and Images

Example

global setup(){
    import("tui")
}

global main(){
    global.tui.init("truecolor");
    global.tui.printText("Hello, TUI!");
    global.tui.panel("Hello", "Title");
    global.tui.clear();
}

See also