Skip to main content

Module program

Module program 

Source
Expand description

Bubbletea/Elm-style runtime for terminal applications.

The program runtime manages the update/view loop, handling events and rendering frames. It separates state (Model) from rendering (View) and provides a command pattern for side effects.

§Example

use ftui_runtime::program::{Model, Cmd};
use ftui_core::event::Event;
use ftui_render::frame::Frame;

struct Counter {
    count: i32,
}

enum Msg {
    Increment,
    Decrement,
    Quit,
}

impl From<Event> for Msg {
    fn from(event: Event) -> Self {
        match event {
            Event::Key(k) if k.is_char('q') => Msg::Quit,
            Event::Key(k) if k.is_char('+') => Msg::Increment,
            Event::Key(k) if k.is_char('-') => Msg::Decrement,
            _ => Msg::Increment, // Default
        }
    }
}

impl Model for Counter {
    type Message = Msg;

    fn update(&mut self, msg: Self::Message) -> Cmd<Self::Message> {
        match msg {
            Msg::Increment => { self.count += 1; Cmd::none() }
            Msg::Decrement => { self.count -= 1; Cmd::none() }
            Msg::Quit => Cmd::quit(),
        }
    }

    fn view(&self, frame: &mut Frame) {
        // Render counter value to frame
    }
}

Structs§

App
Builder for creating and running programs.
AppBuilder
Builder for configuring and running programs.
BatchController
Adaptive batch window controller based on M/G/1 queueing model.
EffectQueueConfig
Configuration for effect queue scheduling.
FrameTiming
Per-frame timing data for profiling.
FrameTimingConfig
Configuration for frame timing capture.
HeadlessEventSource
A no-op event source for headless and test programs.
InlineAutoRemeasureConfig
Policy for remeasuring inline auto UI height.
PaneCapabilityLimitation
Human-readable description of a known limitation and its fallback.
PaneCapabilityMatrix
Resolved capability matrix describing which pane interaction features are available in the current terminal + multiplexer environment.
PaneCleanupDiagnostics
Structured diagnostics emitted when pane interaction state is force-cleaned.
PaneInteractionGuard
RAII guard that ensures pane interaction state is cleanly canceled on drop.
PaneTerminalAdapter
Deterministic terminal adapter mapping raw Event values into schema-validated pane semantic interaction events.
PaneTerminalAdapterConfig
Configuration for terminal-to-pane semantic input translation.
PaneTerminalDispatch
Output of one terminal event translation step.
PaneTerminalLogEntry
Structured translation log entry for one raw terminal event.
PaneTerminalSplitterHandle
One splitter handle region in terminal cell-space.
PersistenceConfig
Configuration for state persistence in the program runtime.
Program
The program runtime that manages the update/view loop.
ProgramConfig
Configuration for the program runtime.
TaskSpec
Scheduling metadata for background tasks.
WidgetRefreshConfig
Configuration for widget refresh selection under render budget.

Enums§

Cmd
Commands represent side effects to be executed by the runtime.
MouseCapturePolicy
Policy controlling when terminal mouse capture is enabled.
PaneMuxEnvironment
Which multiplexer environment the terminal is running inside.
PaneTerminalIgnoredReason
Deterministic reason a terminal event did not map to pane semantics.
PaneTerminalLifecyclePhase
Lifecycle phase observed while translating a terminal event.
PaneTerminalLogOutcome
Translation outcome for one raw terminal event.
ResizeBehavior
Resize handling behavior for the runtime.

Traits§

FrameTimingSink
Sink for frame timing events.
Model
The Model trait defines application state and behavior.

Functions§

pane_terminal_resolve_splitter_target
Resolve a semantic splitter target from a terminal cell position.
pane_terminal_splitter_handles
Build deterministic splitter handle regions for terminal hit-testing.
pane_terminal_target_from_hit
Decode pane resize target from a hit-grid tuple produced by pane handle registration.
register_pane_terminal_splitter_hits
Register pane splitter handles into the frame hit-grid.