hojicha/
lib.rs

1//! # Hojicha
2//!
3//! A Rust framework that brings the Elm Architecture to terminal user interfaces,
4//! built on top of [ratatui](https://github.com/ratatui-org/ratatui).
5//!
6//! ## Overview
7//!
8//! Hojicha provides a structured way to build terminal applications using:
9//! - **Model**: Your application state
10//! - **Message**: Events that trigger state changes  
11//! - **Update**: Pure functions that handle messages and update state
12//! - **View**: Pure functions that render your model to the terminal
13//! - **Command**: Side effects that produce messages
14
15pub mod async_handle;
16pub mod commands;
17pub mod components;
18pub mod core;
19pub mod error;
20pub mod event;
21pub mod metrics;
22pub mod priority_queue;
23pub mod program;
24pub mod queue_scaling;
25pub mod subscription;
26
27#[cfg(test)]
28pub mod testing;
29
30// Re-export core types
31pub use core::{Cmd, Model};
32pub use error::{Error, ErrorContext, ErrorHandler, Result};
33pub use event::{Event, KeyEvent, MouseEvent};
34pub use program::{MouseMode, Program, ProgramOptions};
35
36/// Prelude module for convenient imports
37pub mod prelude {
38    pub use crate::commands::{
39        batch, clear_line, clear_screen, disable_bracketed_paste, disable_focus_change,
40        disable_mouse, enable_bracketed_paste, enable_focus_change, enable_mouse_all_motion,
41        enable_mouse_cell_motion, enter_alt_screen, every, exec, exec_command, exit_alt_screen,
42        hide_cursor, sequence, set_window_title, show_cursor, suspend, tick, window_size,
43    };
44    pub use crate::components::{
45        KeyBinding, KeyMap, List, ListOptions, Spinner, SpinnerStyle, Table, TableOptions,
46        TableRow, TextArea, TextAreaOptions, Viewport, ViewportOptions,
47    };
48    pub use crate::core::{Cmd, Model};
49    pub use crate::error::{Error, ErrorContext, ErrorHandler, Result};
50    pub use crate::event::{Event, Key, KeyEvent, KeyModifiers, MouseEvent, WindowSize};
51    pub use crate::program::{MouseMode, Program, ProgramOptions};
52
53    // Re-export error macros
54    pub use crate::{bail, ensure};
55
56    // Re-export ratatui types users will need
57    pub use ratatui::prelude::*;
58}
59
60#[cfg(test)]
61mod tests {
62    #[test]
63    fn it_works() {
64        // Basic sanity test
65        assert_eq!(2 + 2, 4);
66    }
67}