Skip to content

smelt

Tier: UiHost — Requires a terminal UI; calling these from headless mode raises.

Root smelt namespace. Host-tier bindings are registered first; UiHost-tier bindings are injected when a TUI is active.

smelt.focus

fun(): string

Return which top-level pane currently has focus: "transcript" or "prompt".

smelt.ns

fun(name: string): integer

Look up or allocate a stable namespace id for name. Namespaces scope buf:mark / buf:clear_ns calls so plugins can repaint their region without disturbing others.

smelt.plugin

fun(name: any): any

Promote the current loader frame to plugin scope name and return a small handle exposing the plugin's per-cycle state slot:

local M = smelt.plugin("banner") M.state.fires = 0 -- M.state is smelt.state("banner") M.name == "banner"

After this call, bare smelt.state() also resolves to the named slot and unnamed resource constructors auto-name keyed by name. Idempotent within a single module body run: counters reset on every promotion so declaration order is what matters.

The handle deliberately doesn't wrap smelt.cell / smelt.cmd / smelt.keymap / smelt.lifecycle.* — those calls would not be scope-aware (cell/cmd names are global), so a method facade would imply encapsulation it can't deliver. Call them directly through smelt.* and namespace your cell/cmd names explicitly.

Must be called from a module body (or init.lua). Outside a loader frame (e.g. from an event callback) it raises immediately.

smelt.quit

fun(): nil

Request a clean shutdown of the app. The quit fires on the next tick after the current handler returns.

smelt.sleep

fun(ms: integer): any

Sleep for ms milliseconds. Must be called from inside smelt.spawn(fn) or a tool.execute. Raises cancelled if the task is cancelled while parked.

smelt.spawn

fun(handler: fun()): smelt.Reg

Types: smelt.Reg

Run handler as a coroutine on the Lua task runtime. The handler may yield; its result is discarded. Returns a Reg whose :remove() cancels the task — any in-flight smelt.sleep / smelt.task.wait raises cancelled and the coroutine unwinds.