# hojicha-core
Core abstractions and types for the Hojicha TUI framework implementing The Elm Architecture.
## Purpose
This crate provides the fundamental building blocks for Hojicha applications:
- `Model` trait for application state management
- `Cmd` type for side effects and asynchronous operations
- `Event` enum for all possible events in the system
- Command builders for common operations
## Basic Usage
```rust
use hojicha_core::{Model, Cmd, Event, Message};
use ratatui::Frame;
#[derive(Debug, Clone)]
enum MyMessage {
Increment,
Decrement,
}
impl Message for MyMessage {}
struct MyApp {
counter: i32,
}
impl Model for MyApp {
type Message = MyMessage;
fn init(&mut self) -> Cmd<Self::Message> {
Cmd::none()
}
fn update(&mut self, event: Event<Self::Message>) -> Cmd<Self::Message> {
match event {
Event::User(MyMessage::Increment) => {
self.counter += 1;
Cmd::none()
}
Event::User(MyMessage::Decrement) => {
self.counter -= 1;
Cmd::none()
}
_ => Cmd::none()
}
}
fn view(&self, frame: &mut Frame, area: ratatui::layout::Rect) {
// Render your UI here
}
}
```
## Key Types and Traits
- **`Model`**: The core trait that all Hojicha applications must implement
- **`Message`**: Marker trait for application messages
- **`Cmd<M>`**: Represents side effects and commands to be executed
- **`Event<M>`**: All possible events (keyboard, mouse, user messages, etc.)
## Documentation
For full documentation and more examples, see the [main Hojicha documentation](https://codeberg.org/emes/hojicha).
## License
GPL-3.0 - See LICENSE file for details