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.
- Batch
Controller - Adaptive batch window controller based on M/G/1 queueing model.
- Effect
Queue Config - Configuration for effect queue scheduling.
- Frame
Timing - Per-frame timing data for profiling.
- Frame
Timing Config - Configuration for frame timing capture.
- Headless
Event Source - A no-op event source for headless and test programs.
- Inline
Auto Remeasure Config - Policy for remeasuring inline auto UI height.
- Pane
Capability Limitation - Human-readable description of a known limitation and its fallback.
- Pane
Capability Matrix - Resolved capability matrix describing which pane interaction features are available in the current terminal + multiplexer environment.
- Pane
Cleanup Diagnostics - Structured diagnostics emitted when pane interaction state is force-cleaned.
- Pane
Interaction Guard - RAII guard that ensures pane interaction state is cleanly canceled on drop.
- Pane
Terminal Adapter - Deterministic terminal adapter mapping raw
Eventvalues into schema-validated pane semantic interaction events. - Pane
Terminal Adapter Config - Configuration for terminal-to-pane semantic input translation.
- Pane
Terminal Dispatch - Output of one terminal event translation step.
- Pane
Terminal LogEntry - Structured translation log entry for one raw terminal event.
- Pane
Terminal Splitter Handle - One splitter handle region in terminal cell-space.
- Persistence
Config - Configuration for state persistence in the program runtime.
- Program
- The program runtime that manages the update/view loop.
- Program
Config - Configuration for the program runtime.
- Task
Spec - Scheduling metadata for background tasks.
- Widget
Refresh Config - Configuration for widget refresh selection under render budget.
Enums§
- Cmd
- Commands represent side effects to be executed by the runtime.
- Mouse
Capture Policy - Policy controlling when terminal mouse capture is enabled.
- Pane
MuxEnvironment - Which multiplexer environment the terminal is running inside.
- Pane
Terminal Ignored Reason - Deterministic reason a terminal event did not map to pane semantics.
- Pane
Terminal Lifecycle Phase - Lifecycle phase observed while translating a terminal event.
- Pane
Terminal LogOutcome - Translation outcome for one raw terminal event.
- Resize
Behavior - Resize handling behavior for the runtime.
Traits§
- Frame
Timing Sink - 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.