Tuix.Terminal.ANSI (tuix v0.1.0)

Copy Markdown View Source

Builders for the ANSI escape sequences on the frame-rendering hot path.

All functions return iodata suitable for writing directly to the terminal.

Why not io_ansi?

Tuix uses OTP 29's :io_ansi for static terminal control (alternate screen, cursor visibility, keypad mode - see Tuix.Terminal), where its terminfo awareness helps. The sequences here are emitted per frame diff: they are universal, and building them directly lets the renderer batch multiple SGR codes into a single sequence per run, which :io_ansi's one-sequence-per-attribute API cannot do.

Summary

Functions

SGR codes for a text attribute.

Clear the entire screen.

Move the cursor to a 0-based {x, y} position.

Reset all styling attributes.

Build an SGR sequence from a list of numeric codes.

Functions

attr_code(atom)

SGR codes for a text attribute.

clear_screen()

Clear the entire screen.

move_to(x, y)

Move the cursor to a 0-based {x, y} position.

The terminal itself is 1-based; this function does the translation.

reset()

Reset all styling attributes.

sgr(codes)

Build an SGR sequence from a list of numeric codes.

Returns an empty list when no codes are given.