TerminalRunner

io.worxbend.tui.runtime.TerminalRunner
See theTerminalRunner companion object
final class TerminalRunner(backend: Backend, config: RunnerConfig = ..., nanoTime: () => Long = ..., redrawRequested: () => Boolean = ..., onStop: () => Unit = ...) extends Runner

The production Runner: raw mode + alternate screen setup, diff-driven redraws, tick emission, resize handling, and render-thread registration around a Backend.

nanoTime is injectable so tick scheduling and opt-in frame phase timing are testable; production code uses the system's monotonic elapsed-time clock, not a CPU-time clock.

redrawRequested is the host's own "is a frame owed?" question, asked once per iteration — a TuiApp answers it from its signal-invalidation flag. It is read alongside, not instead of, RunnerHandle.requestRedraw: the handle serves code that has no reactive state to invalidate.

onStop is the registered-loop teardown seam: it runs once on the owner thread after a bounded final queued-work drain (at most 256 callbacks per queue), before the queue is closed, the owner is unregistered and the backend is closed. Remaining owned callbacks are discarded; running callbacks are never interrupted. It also runs after partial setup failure. Use it to dispose thread-confined subscriptions and services. Every release is attempted even if an earlier one throws; a prior run failure stays primary, with secondary failures exposed by RunnerError.cleanupFailures (and suppressed on its throwable when it has one). A first non-fatal teardown throwable is returned as RunnerError.Handler; fatal throwables escape only after cleanup completes.

Attributes

Companion
object
Graph
Supertypes
trait Runner
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

def run(onStart: RunnerHandle => Unit, handleEvent: (Event, RunnerHandle) => EventOutcome, render: Frame => Unit): Either[RunnerError, Unit]