Expand description
§Hojicha
The Elm Architecture for Terminal UIs in Rust.
This is a convenience facade that re-exports the core hojicha crates:
hojicha-core: Core TEA abstractions (Model, Cmd, Event)hojicha-runtime: Event loop and async runtime (Program)
§Quick Start
use hojicha::prelude::*;
struct Counter {
value: i32,
}
impl Model for Counter {
type Message = ();
fn update(&mut self, event: Event<()>) -> Cmd<()> {
match event {
Event::Key(key) => match key.key {
Key::Up => self.value += 1,
Key::Down => self.value -= 1,
Key::Char('q') => return quit(),
_ => {}
},
_ => {}
}
Cmd::noop()
}
fn view(&self) -> String {
// Return a string with ANSI codes for terminal rendering
format!("Count: {}", self.value)
}
}
fn main() -> Result<()> {
Program::new(Counter { value: 0 })?.run()
}Modules§
- async_
helpers - High-level async helper commands for common operations
- commands
- Command utilities for handling side effects
- concurrency
- Concurrency safety utilities and patterns
- core
- Core traits and types for the Elm Architecture
- debug
- Debugging and developer ergonomics tools
- event
- Event handling for keyboard, mouse, and other terminal events
- fallible
- Fallible model support for error handling in the update cycle
- panic_
recovery - Panic recovery utilities for Model trait methods
- prelude
- Prelude module containing commonly used types and traits
- program
- The main Program struct that runs the application
Structs§
- Cmd
- A command is an asynchronous operation that produces a message.
- KeyEvent
- A keyboard event
- KeyModifiers
- Represents key modifiers (shift, control, alt, etc.).
- Mouse
Event - A mouse event
- Program
- The main program that runs your application
- Window
Size - Window size information
Enums§
- Event
- An event that can be received by the program
- Key
- Represents a key on the keyboard
- Mouse
Button - Represents a mouse button.
- Mouse
Event Kind - A mouse event kind.
Traits§
- Message
- A message that can be sent to update the model.
- Model
- The core trait for your application’s model.
Functions§
- run
- Convenience function to run a Hojicha application