Expand description
§Cauldron
A powerful TUI framework based on The Elm Architecture.
Cauldron is the Rust equivalent of bubbletea from Charmbracelet. It provides a simple, functional approach to building terminal user interfaces.
§The Elm Architecture
Cauldron follows The Elm Architecture (TEA):
- Model - Your application state
- Message - Events that can update the state
- Update - A function that updates the model based on messages
- View - A function that renders the model to the terminal
§Quick Start
use cauldron::{App, Command, Model};
// Define your model
struct Counter {
count: i32,
}
// Define your messages
enum Msg {
Increment,
Decrement,
Quit,
}
impl Model for Counter {
type Message = Msg;
fn update(&mut self, msg: Self::Message) -> Command<Self::Message> {
match msg {
Msg::Increment => self.count += 1,
Msg::Decrement => self.count -= 1,
Msg::Quit => return Command::quit(),
}
Command::none()
}
fn view(&self) -> String {
format!("Count: {}\n\nPress +/- to change, q to quit", self.count)
}
}
fn main() {
let counter = Counter { count: 0 };
cauldron::run(counter).unwrap();
}§Features
- Simple API - Just implement
Modeland you’re done - Async Support - Commands can spawn async tasks
- Key Handling - Built-in keyboard input handling
- Mouse Support - Optional mouse event handling
- Alternate Screen - Automatic alternate screen buffer management
Structs§
- App
- A builder for creating and running Cauldron applications.
- Command
- A command that can be returned from
update. - KeyModifiers
- Key modifiers (Ctrl, Alt, Shift).
- Mouse
Event - A mouse event.
- Program
- The main program that runs the TUI application.
- Program
Options - Options for configuring the program.
- Renderer
- Renders content to the terminal.
Enums§
Traits§
- Model
- The core trait for Cauldron applications.
Functions§
- batch
- Batch multiple commands together.
- run
- Run a model as a full-screen TUI application.
- run_
with_ options - Run a model with custom options.
Type Aliases§
- Cmd
- Alias for Command (matches bubbletea naming).