Crate tuyere

Crate tuyere 

Source
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):

  1. Model - Your application state
  2. Message - Events that can update the state
  3. Update - A function that updates the model based on messages
  4. 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 Model and 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).
MouseEvent
A mouse event.
Program
The main program that runs the TUI application.
ProgramOptions
Options for configuring the program.
Renderer
Renders content to the terminal.

Enums§

Event
An event from the terminal.
Key
A keyboard key.

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).