Skip to main content

ratkit/
lib.rs

1//! # ratkit - Core runtime for ratkit TUI components
2//!
3//! ratkit provides the core runtime (Runner + Layout Manager) and optional
4//! re-exports for ratkit TUI components. Enable only the features you need or
5//! use the `all` feature for the full bundle.
6//!
7//! # Installation
8//!
9//! ```toml
10//! [dependencies]
11//! ratkit = "0.1"
12//! ```
13//!
14//! For the core runtime only:
15//!
16//! ```toml
17//! ratkit = "0.1"
18//! ```
19//!
20//! For selected components:
21//!
22//! ```toml
23//! ratkit = { version = "0.1", default-features = false, features = ["tree-view", "toast"] }
24//! ```
25//!
26//! For the full bundle:
27//!
28//! ```toml
29//! ratkit = { version = "0.1", features = ["all"] }
30//! ```
31//!
32//! # Quick Start
33//!
34//! ```rust,no_run
35//! use ratkit::prelude::*;
36//! use ratatui::Frame;
37//!
38//! struct MyApp;
39//!
40//! impl CoordinatorApp for MyApp {
41//!     fn on_event(&mut self, _event: CoordinatorEvent) -> LayoutResult<CoordinatorAction> {
42//!         Ok(CoordinatorAction::Continue)
43//!     }
44//!
45//!     fn on_draw(&mut self, _frame: &mut Frame) {}
46//! }
47//!
48//! fn main() -> std::io::Result<()> {
49//!     run(MyApp, RunnerConfig::default())
50//! }
51//! ```
52//!
53//! With widget features enabled, import UI primitives from `ratkit::widgets`.
54//!
55//! # Feature Flags
56//!
57//! - `default`: Core runtime only (Runner + Layout Manager)
58//! - `all`: All widgets and services
59//! - `full`: Alias for `all`
60//! - `widgets`: All UI widgets
61//! - `services`: All service components
62//! - Individual feature flags for each component
63
64#![doc(html_root_url = "https://docs.rs/ratkit/0.1")]
65#![warn(missing_docs, clippy::cargo)]
66#![cfg_attr(doc, cfg(feature = "docsrs"))]
67
68mod coordinator;
69mod error;
70mod events;
71mod focus;
72mod layout;
73mod mouse_router;
74mod redraw_signal;
75mod registry;
76mod runner_helper;
77mod types;
78
79/// Core runtime pieces for ratkit.
80pub mod core;
81
82/// Feature-gated primitive widget modules.
83pub mod primitives;
84
85/// Feature-gated widget modules (includes primitives for backward compatibility).
86pub mod widgets;
87
88/// Feature-gated service modules.
89pub mod services;
90
91pub use runner_helper::{run, run_with_diagnostics};
92
93pub use core::{
94    CoordinatorAction, CoordinatorApp, CoordinatorConfig, CoordinatorEvent, Element, ElementHandle,
95    ElementId, ElementMetadata, FocusRequest, KeyboardEvent, LayoutCoordinator, LayoutError,
96    LayoutResult, MouseEvent, MouseRouterConfig, RedrawSignal, ResizeEvent, Runner, RunnerAction,
97    RunnerConfig, RunnerEvent, TickEvent, Visibility,
98};
99
100/// Runner-first imports for applications.
101pub mod prelude {
102    pub use crate::{
103        run, run_with_diagnostics, CoordinatorAction, CoordinatorApp, CoordinatorConfig,
104        CoordinatorEvent, KeyboardEvent, LayoutResult, MouseEvent, MouseRouterConfig, ResizeEvent,
105        Runner, RunnerAction, RunnerConfig, RunnerEvent, TickEvent,
106    };
107}