tuirealm/
lib.rs

1#![cfg_attr(docsrs, feature(doc_cfg))]
2
3//! # tui-realm
4//!
5//! tui-realm is a **framework** for **[ratatui](https://github.com/ratatui-org/ratatui)**
6//! to simplify the implementation of terminal user interfaces adding the possibility to work
7//! with re-usable components with properties and states, as you'd do in React. But that's not all:
8//! the components communicate with the ui engine via a system based on **Messages** and **Events**,
9//! providing you with the possibility to implement `update` routines as happens in Elm.
10//!
11//! In addition, the components are organized inside the **View**, which manages mounting/umounting,
12//! focus and event forwarding for you.
13//!
14//! tui-realm also comes with a standard library of components, which can be added to your dependencies,
15//! that you may find very useful.
16//!
17//! ## Get started 🏁
18//!
19//! > ⚠️ Warning: currently tui-realm supports these backends: crossterm, termion
20//!
21//! ### Add tui-realm to your Cargo.toml 🦀
22//!
23//! If you want the default features, just add tuirealm 1.x version:
24//!
25//! ```toml
26//! tuirealm = "3"
27//! ```
28//!
29//! otherwise you can specify the features you want to add:
30//!
31//! ```toml
32//! tuirealm = { version = "3", default-features = false, features = [ "derive", "serialize", "termion" ] }
33//! ```
34//!
35//! Supported features are:
36//!
37//! - `derive` (*default*): add the `#[derive(MockComponent)]` proc macro to automatically implement `MockComponent` for `Component`. [Read more](https://github.com/veeso/tuirealm_derive).
38//! - `async-ports`: add support for async ports
39//! - `serialize`: add the serialize/deserialize trait implementation for `KeyEvent` and `Key`.
40//! - `crossterm`: use the [crossterm](https://github.com/crossterm-rs/crossterm) terminal backend
41//! - `termion`: use the [termion](https://github.com/redox-os/termion) terminal backend
42//!
43//! ### Create a tui-realm application 🪂
44//!
45//! You can read the guide to get started with tui-realm on [Github](https://github.com/veeso/tui-realm/blob/main/docs/en/get-started.md)
46//!
47//! ### Run examples 🔍
48//!
49//! Still confused about how tui-realm works? Don't worry, try with the examples:
50//!
51//! - [demo](https://github.com/veeso/tui-realm/blob/main/examples/demo.rs): a simple application which shows how tui-realm works
52//!
53//!    ```sh
54//!    cargo run --example demo
55//!    ```
56//!
57
58#![doc(html_playground_url = "https://play.rust-lang.org")]
59#![doc(
60    html_favicon_url = "https://raw.githubusercontent.com/veeso/tui-realm/main/docs/images/cargo/tui-realm-128.png"
61)]
62#![doc(
63    html_logo_url = "https://raw.githubusercontent.com/veeso/tui-realm/main/docs/images/cargo/tui-realm-512.png"
64)]
65
66#[macro_use]
67extern crate lazy_regex;
68extern crate self as tuirealm;
69#[cfg(feature = "derive")]
70#[allow(unused_imports)]
71#[macro_use]
72extern crate tuirealm_derive;
73
74mod core;
75pub mod listener;
76pub mod macros;
77#[cfg(test)]
78pub mod mock;
79pub mod ratatui;
80pub mod terminal;
81pub mod utils;
82// export async trait for async-ports
83#[cfg(feature = "async-ports")]
84#[cfg_attr(docsrs, doc(cfg(feature = "async-ports")))]
85pub use async_trait::async_trait;
86pub use listener::{EventListenerCfg, ListenerError};
87// -- derive
88#[cfg(feature = "derive")]
89#[doc(hidden)]
90pub use tuirealm_derive::*;
91
92pub use self::core::application::{self, Application, ApplicationError, PollStrategy};
93pub use self::core::event::{self, Event, NoUserEvent};
94pub use self::core::injector::Injector;
95pub use self::core::props::{self, AttrValue, Attribute, Props};
96pub use self::core::subscription::{EventClause as SubEventClause, Sub, SubClause};
97pub use self::core::{Component, MockComponent, State, StateValue, Update, ViewError, command};
98pub use self::ratatui::Frame;