class

TUI::Runtime

Inherits Reference < Object

Owns the generic TUI application lifecycle: terminal setup/teardown, the render/read-key/dispatch loop, SIGWINCH-driven resize, and the push/pop/render mechanics of a stack of full-screen Widgets. Consumers build their own widgets, wrap them in a NavStack(Widget), and hand it here along with a callback for everything that isn't Ctrl-C/Ctrl-D — this class owns no opinion about what any printable key (including 'q') should do.

Once a Runtime owns a NavStack, push/pop through Runtime#push/#pop (not NavStack#push/#pop or #handle_esc directly) so revealed/pushed widgets get resized to the current screen before their next render.

Constructors

new(screen : Screen, nav : NavStack(Widget), on_key : KeyEvent -> Nil, io : IO = STDIN)
Source

Instance methods

handle_esc(consumed : Bool, &on_pop : -> ) : Nil

The "delegate to child, pop only if unconsumed" idiom for Esc, routed through Runtime#pop (not NavStack#pop directly) so the revealed widget gets resized in case it went stale while backgrounded — mirrors NavStack#handle_esc's contract exactly, but callers that own a Runtime should use this one instead.

Source
pop

Pop back to the previous widget, resyncing its size in case it went stale while backgrounded.

Source
push(widget : Widget) : Nil

Push a widget, resizing it to the current screen first.

Source
read_dispatch_loop

The render/read-key/dispatch loop itself, without the surrounding terminal setup/teardown/signal trap — split out so it's exercisable against an injected IO (see @io) without touching real terminal state, e.g. in specs.

Source
render_now

Forces a synchronous full render+flush outside the normal read/dispatch loop. Intended for a long blocking operation (e.g. a pkg apply) that emits progress via callbacks and needs the screen repainted between the loop's normal render points.

Source
replace_base(widget : Widget) : Nil

Swaps the widget at the bottom of the stack, resizing it to the current screen first — for a root screen whose structure changes based on runtime state.

Source