Luau Bindings — terminal

The require("terminal") script API (aliased term) — coloured, attributed output for ordinary scripts, and a full-screen application mode (cursor, key input, glyph set) for interactive tools. Every function is [antos]. Design & native core: antos_terminal.

local term = require("terminal")
term.color("green"); term.print("ok"); term.reset()

Two levels: line output (any script) and application mode (interactive tools, with a required init/teardown lifecycle).


Line output — no lifecycle needed

Function Behaviour
term.print(...) Print with current attributes; newline.
term.write(...) Print, no trailing newline.
term.color(fg [, bg]) Set colour — name ("red", "bright_white"), index, or r,g,b.
term.attr(t) { bold, dim, underline, invert, blink }.
term.reset() Reset colour/attributes.
term.cols() · term.rows() Terminal size.
term.supports(feature) Capability query ("color", "truecolor", "glyphs", …).

Keep output within the console glyph set — ASCII, box-drawing, block/shade, Braille, a few icons; use -> not →, no emoji. See the Quickstart glyph section.


Application mode — init / shutdown required

Function Behaviour
term.init([opts]) Enter application mode: alternate screen, raw key input, hidden cursor. opts e.g. { mouse=true }.
term.shutdown() Restore the console. Always call this, on every exit path.
term.clear() Clear the screen.
term.move(col, row) Position cursor (1-based).
term.cursor(show) Show/hide cursor.
term.key([timeout]) Read a key event: { key, char, ctrl, alt, shift }; timeout ms (nil = block).
term.glyph(name) A console glyph from the AntOS set.

The safe pattern — teardown guaranteed even on error:

local term = require("terminal")
term.init()
local ok, err = pcall(function()
  term.clear(); term.move(1,1); term.print("q to quit")
  repeat until term.key().char == "q"
end)
term.shutdown()          -- runs whether the body succeeded or errored
if not ok then error(err) end

term.shutdown() must precede every return. Application mode is also mirrored to the netImgui remote UI where available.


Related

Important: The Ant64 family of home computers are at early design/prototype stage, everything you see here is subject to change.