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.
- Inline
Auto Remeasure Config - Policy for remeasuring inline auto UI height.
- 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.
- 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.