runtime library

Stable core runtime entrypoint for interactive terminal applications.

Prefer this library when you want the supported Elm-style TUI surface without pulling in the broader package:artisanal/tui.dart extras such as bubbles, markdown helpers, or the high-level widget re-export.

This entrypoint includes:

  • Model, Msg, Cmd, Program, and ProgramOptions
  • the built-in key, mouse, resize, clipboard, and terminal report messages
  • StringTerminal for deterministic runtime and host tests
  • View metadata types and terminal theme helpers
  • replay and trace utilities for deterministic debugging

Classes

BackgroundColorMsg
Message containing the terminal's background color.
BatchMsg
Message containing multiple messages to be processed sequentially.
CapabilityMsg
Message sent when a terminal capability is reported.
CellSizeMsg
Message sent when the terminal reports its cell size in pixels.
ClearScreenMsg
Internal message to clear the screen.
ClipboardMsg
Clipboard content message.
ClipboardSetMsg
Message emitted after a best-effort clipboard write is attempted.
Cmd TUI
A command that produces a message asynchronously.
ColorPaletteMsg
Message containing a terminal palette entry color.
ColorProfileMsg
Message sent when the terminal color profile is detected or changed.
ColorSchemeMsg
Message sent when the terminal reports its preferred light/dark scheme.
CompositeModel
A model that wraps another model, useful for composition.
CursorColorMsg
Message containing the terminal's cursor color.
CursorPositionMsg
Message sent when the terminal reports the cursor position.
CustomMsg<T>
Message wrapper for custom user-defined messages.
DisableBracketedPasteMsg
Internal message to disable bracketed paste.
DisableMouseMsg
Internal message to disable mouse tracking.
DisableReportFocusMsg
Internal message to disable focus reporting.
EnableBracketedPasteMsg
Internal message to enable bracketed paste.
EnableMouseAllMotionMsg
Internal message to enable mouse all motion tracking.
EnableMouseCellMotionMsg
Internal message to enable mouse cell motion tracking.
EnableReportFocusMsg
Internal message to enable focus reporting.
EnterAltScreenMsg
Internal message to enter alt screen.
EveryCmd
A repeating command that fires at regular intervals.
ExecProcessMsg
Message signaling that an external process should be executed.
ExecResult
Result of executing an external process.
ExitAltScreenMsg
Internal message to exit alt screen.
FocusMsg
Message sent when focus is gained or lost.
ForegroundColorMsg
Message containing the terminal's foreground color.
FrameTickModel
Optional interface for models that want to control frame ticks.
FrameTickMsg
Message sent automatically by the TUI runtime every frame.
HideCursorMsg
Internal message to hide cursor.
HitTestMouseMsg
Message dispatched to an element when render-tree hit-testing determines that a MouseMsg landed within its render object's bounds.
InterruptMsg
Message sent when the runtime receives a terminal interrupt.
Key
Represents a parsed keyboard input event.
KeyboardEnhancements
KeyboardEnhancements describes the requested keyboard enhancement features.
KeyboardEnhancementsMsg
Message sent when keyboard enhancements are reported.
KeyMsg
Message sent when a key is pressed.
KeyParser
Parses raw terminal input bytes into Key objects and Msg objects.
Keys
Key constants and utilities for keyboard input handling.
Model TUI
Abstract interface for TUI application models.
ModeReportMsg
Message sent when the terminal replies to a mode status query.
ModifyOtherKeysMsg
Message sent when the terminal reports a ModifyOtherKeys mode.
MouseMsg
Message sent for mouse events.
Msg TUI
Base class for all messages in the TUI runtime.
PaneLayout
A complete computed layout for all leaf panes and split handles.
PaneLeaf
PaneRect
Rectangle coordinates for leaf pane geometry.
PaneSnapTarget
A target split handle used for snap behavior.
PaneSplit
PaneTreeNode
ParallelCmd
A command that executes multiple commands in parallel through the Program's command execution system.
PasteMsg
Message sent when bracketed paste content is received.
PrimaryDeviceAttributesMsg
Message sent when the terminal replies with primary device attributes.
PrintLineMsg
Message for printing a line above the program output.
Program<M extends Model> TUI
The TUI program runtime.
ProgramHost
Reusable launch target for a Program.
ProgramHostBinding
Resolved runtime configuration produced by a ProgramHost.
ProgramInterceptor
Intercepts program messages and lifecycle events.
ProgramMacro
Recorded user-input macro that can be replayed later.
ProgramOptions
Options for configuring the TUI program.
ProgramReplay
Message replay source for ProgramOptions.replay.
ProgramReplayStep
One replay step for ProgramReplay.script.
QuitMsg
Internal message signaling that the program should quit.
RenderBudgetController
Tracks render budget pressure and adjusts degradation levels.
RenderBudgetMsg
Message sent when the runtime changes render-budget degradation state.
RenderBudgetOptions
Configuration for budget-aware render degradation.
RenderBudgetState
The current state of a RenderBudgetController.
RenderMetricsModel
Optional interface for models that want render metrics updates.
RenderMetricsMsg
Message sent periodically with renderer performance metrics.
RepaintMsg
Message sent to force a repaint of the view.
RepaintRequestMsg
Internal message to request a repaint.
ReplayAction
Replay action schema used by TUI scenario JSON files.
ReplayCoordinateInterceptor
Coordinate interceptor that scales replay mouse coordinates to current runtime window dimensions.
ReplayCustomEvent
Structured custom event embedded in replay actions.
ReplayEventDirective
Hook decision produced for ReplayCustomEvent actions.
ReplayEventMsg
Replay message emitted for custom event actions.
ReplayMouseMsg
Replay-only mouse message marker.
ReplayScenario
Replay scenario document.
ReplayScreen
Screen metadata captured for replay coordinate scaling.
ReplayTraceConversionOptions
Trace conversion options for ReplayTraceConverter.
ReplayTraceConversionResult
Conversion output returned by ReplayTraceConverter.convertFile.
ReplayTraceConverter
Converts TuiTrace logs into replay scenarios.
RequestWindowSizeMsg
Internal message to request window size.
ResumeMsg
Message sent when the program resumes from suspension.
SecondaryDeviceAttributesMsg
Message sent when the terminal replies with secondary device attributes.
SetWindowTitleMsg
Internal message to set window title.
ShowCursorMsg
Internal message to show cursor.
SplitHandle
Geometry for a split handle used by resize/snap calculations.
StreamCmd<T>
A command that manages a stream subscription.
StringTerminal
A terminal that captures output to a string buffer (for testing).
SuspendMsg
Message signaling the program should suspend (like Ctrl+Z).
TerminalProgressBar
TerminalProgressBar represents the terminal taskbar progress (OSC 9;4).
TerminalThemeState
Tracks terminal theme information (background + dark/light heuristic).
TerminalVersionMsg
Message sent when the terminal version is reported.
TertiaryDeviceAttributesMsg
Message sent when the terminal replies with tertiary device attributes.
TickMsg
Message sent when a timer tick occurs.
TilingPaneManager
Immutable tiling pane manager with split tree and focused pane id.
TraceEventRecord
A structured event decoded from one trace log line.
TraceEventType
Structured trace event names emitted by TuiTrace.event.
TraceSpan
A timing span for hierarchical tracing.
TuiEvidence
Optional evidence logger for structured runtime diagnostics.
TuiEvidenceRecord
A decoded evidence event line.
TuiTrace
Lightweight debug tracer for TUI frame rendering and message dispatch.
UvEventMsg
Raw Ultraviolet event message (only emitted when UV input decoding is enabled).
View TUI
View represents a terminal view that can contain metadata for terminal control.
ViewDegradation
Opt-in degraded content stages for a View.
WindowPixelSizeMsg
Message sent when the terminal window reports its pixel dimensions.
WindowSizeMsg
Message sent when the terminal window is resized.
ZoneInBoundsMsg
Message sent when a zone is within bounds of a mouse event.

Enums

ClipboardSelection
Clipboard selection targets for OSC 52 operations.
ClipboardSetMethod
Clipboard write transport used by ClipboardSetMsg.
DegradationLevel
Ordered render degradation levels used by the runtime.
KeyType
Types of keyboard input events.
ModeReportValue
The reported state of a terminal mode query.
MouseAction
Mouse event action types.
MouseButton
Mouse button identifiers.
MouseMode
Mouse tracking modes for the terminal.
PaneNavigationDirection
Navigation direction used for focus traversal.
PaneSnapAlignment
Snap alignment for drag gestures near a split handle.
PaneSplitDirection
Direction for pane geometry splits.
ReplayEventControl
Replay control decision for a custom replay event.
ScreenMode
Controls how the TUI renders relative to the terminal's primary screen.
TerminalProgressBarState
TerminalProgressBarState represents the state of the terminal taskbar progress.
TraceTag
Trace categories for filtering and grouping trace output.
UiAnchor
Which edge of the terminal the inline UI region is anchored to.

Mixins

CopyWithModel
Mixin that documents the copyWith pattern for models.
TerminalThemeHost
Mixin for models/components that want terminal theme state with minimal boilerplate.

Extensions

CmdExtension on Cmd?
Extension methods for nullable Cmd.

Functions

every(Duration interval, Msg? callback(DateTime time), {Object? id}) Cmd
Helper to create a repeating timer command.
noCmd(Model model) UpdateResult
Helper function to create an update result with no command.
quit(Model model) UpdateResult
Helper function to create an update result that quits.
replayScenarioStream(List<ReplayAction> actions, {required bool loop, required bool keepOpen, required double speed, ReplayEventHook? eventHook}) Stream<Msg>
Builds a replay message stream from a list of replay actions.
runProgram<M extends Model>(M model, {ProgramOptions options = const ProgramOptions(), ProgramHost? host, TuiTerminal? terminal}) Future<void>
Runs a TUI program with the given model.
runProgramDebug<M extends Model>(M model, {ProgramOptions? options, ProgramHost? host, TuiTerminal? terminal}) Future<void>
Runs a TUI program without panic catching (for debugging).
runProgramWithResult<M extends Model>(M model, {ProgramOptions options = const ProgramOptions(), ProgramHost? host, TuiTerminal? terminal}) Future<M>
Runs a TUI program and returns the final model after exit.

Typedefs

CmdFunc = Cmd Function()
Type alias for a function that creates commands.
CmdFunc1<T> = Cmd Function(T value)
Type alias for a function that creates commands from a value.
MessageFilter = Msg? Function(Model model, Msg msg)
A function that filters messages before they reach the model.
ProgramHostResolver = ProgramHostBinding Function(ProgramOptions options)
Resolves a reusable launch target for a Program.
ReplayEventHook = FutureOr<ReplayEventDirective?> Function(ReplayCustomEvent event)
Hook invoked when replay reaches an event action.
UpdateResult = (Model, Cmd?)
Type alias for the update function return type.

Exceptions / Errors

ProgramCancelledError
Error thrown when a program is cancelled via an external signal.