Expand description
Easy-mode adapter for string-based views.
StringModel provides a simpler alternative to the full Model trait
for applications that render their view as a string rather than directly
manipulating a Frame. The string is parsed as styled text and rendered
into the frame automatically.
This preserves the full kernel pipeline: String -> Text -> Frame -> Diff -> Presenter.
§Example
ⓘ
use ftui_runtime::string_model::StringModel;
use ftui_runtime::program::Cmd;
use ftui_core::event::Event;
struct Counter { count: i32 }
enum Msg { Increment, Quit }
impl From<Event> for Msg {
fn from(_: Event) -> Self { Msg::Increment }
}
impl StringModel for Counter {
type Message = Msg;
fn update(&mut self, msg: Msg) -> Cmd<Msg> {
match msg {
Msg::Increment => { self.count += 1; Cmd::none() }
Msg::Quit => Cmd::quit(),
}
}
fn view_string(&self) -> String {
format!("Count: {}", self.count)
}
}Structs§
- String
Model Adapter - Adapter that bridges a
StringModelto the fullModeltrait.
Traits§
- String
Model - A simplified model trait that uses string-based views.