1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
//! # termint
//!
//! [](https://crates.io/crates/termint)
//! [](https://docs.rs/termint/latest/termint/)
//! [](https://crates.io/crates/termint)
//!
//! **termint** is high-performance, structural TUI (Terminal User Interface)
//! library and framework for Rust.
//!
//! ## Table of Contents
//!
//! - [How to get it](#how-to-get-it)
//! - [With cargo](#with-cargo)
//! - [In Cargo.toml](#in-cargotoml)
//! - [Features](#features)
//! - [Examples](#examples)
//! - [Framework Mode](#framework-mode)
//! - [Manual Mode](#manual-mode)
//! - [Colored printing](#colored-printing)
//! - [TUI examples](#tui-examples)
//! - [Usage](#usage)
//! - [Projects](#projects)
//! - [Links](#links)
//!
//! ## How to get it
//!
//! This crate is available on [crates.io](https://crates.io/crates/termint).
//!
//! ### With cargo
//!
//! ```terminal
//! cargo add termint
//! ```
//!
//! ### In Cargo.toml
//!
//! ```toml
//! [dependencies]
//! termint = "0.8.1"
//! ```
//!
//! ### Features
//!
//! - `backend-crossterm`: Enables [Crossterm](https://crates.io/crates/crossterm)
//! as the event-reading backend.
//! - `backend-termal`: Enables [Termal](https://crates.io/crates/termal) as the
//! event-reading backend.
//! - `serde`: Enables serialization and deserialization of some structs.
//! - `all`: Enables all features.
//!
//! `backend-crossterm` is enabled by default. If both `backend-crossterm` and
//! `backend-termal` are enabled, Termint defaults to **Crossterm**, unless
//! specified otherwise via `Term::<Message, Backend>::init()`.
//!
//! ## Examples
//!
//! ### Framework Mode
//!
//! > **Note:** To use `Framework mode`, you must enable either the
//! > `backend-crossterm` or `backend-termal` feature.
//!
//! Termint provides the `Application` trait to manage the UI lifecycle. You can
//! then use `Term::run`, which runs the main loop, handles the input events and
//! efficient rendering all using the given `Application` implementation.
//!
//! ```rust,no_run
//! use termint::prelude::*;
//!
//! struct MyApp;
//!
//! impl Application for MyApp {
//! type Message = ();
//!
//! fn view(&self, _frame: &Frame) -> Element<Self::Message> {
//! let mut main = Block::vertical().title("Termint App");
//! main.push("Hello from the Application trait!".fg(Color::Cyan), 0..);
//! main.into()
//! }
//!
//! fn event(&mut self, event: Event) -> Action {
//! match event {
//! Event::Key(k) if k.code == KeyCode::Char('q') => Action::QUIT,
//! _ => Action::NONE,
//! }
//! }
//! }
//!
//! fn main() -> Result<(), Error> {
//! Term::default().setup()?.run(&mut MyApp)
//! }
//! ```
//!
//! ### Manual Mode
//!
//! If you prefer to manage you own loop, you can use the manual mode, where
//! `Term` manages only terminal state and rendering. Everything else, such as the
//! main loop, event handling and so on, you have to implement yourself.
//!
//! ```rust,no_run
//! use termint::prelude::*;
//!
//! fn main() -> Result<(), Error> {
//! let mut term = Term::<(), _>::default().setup()?;
//! loop {
//! // 1. Custom event handling
//! // 2. Logic updates
//!
//! let mut main = Block::vertical().title("Termint App");
//! main.push("Hello from the Manual mode!".fg(Color::Red), 0..);
//!
//! // 3. Render on demand
//! term.render(main)?;
//! }
//! }
//! ```
//!
//! ### Colored printing
//!
//! Colored printing is really easy, you can do it by using any `Text` widget.
//! Here is an example of using `Span` widget:
//!
//! ```rust
//! use termint::prelude::*;
//!
//! println!("{}", "Cyan text".fg(Color::Cyan));
//! println!("{}", "Cyan text on white".fg(Color::Cyan).bg(Color::White));
//! println!("{}", "Bold red text".fg(Color::Red).modifier(Modifier::BOLD));
//! println!("{}", "Text with RGB value".fg(Color::Rgb(0, 249, 210)));
//! ```
//!
//! 
//!
//! You can also use re-exported `termal` crate to print colored text:
//!
//! ```rust
//! use termint::termal::printcln;
//!
//! printcln!("{'yellow italic}Yellow Italic text{'reset}");
//! printcln!("{'y i}{}{'_}", "Yellow Italic text");
//! printcln!("{'#dd0 i}{}{'_}", "Custom Yellow Italic text");
//! ```
//!
//! ### TUI examples
//!
//! 
//!
//! 
//!
//! 
//!
//! ## Usage
//!
//! Code blocks above are just examples of the usage. To see more about functions,
//! Widgets and more, please visit the
//! [documentation](https://docs.rs/termint/latest/termint/).
//!
//! You can also check the `examples` directory of this repository for more
//! examples of how to use this crate for creating TUIs.
//!
//! ## Projects
//!
//! Here is a list of some projects using termint:
//!
//! - [2048](https://github.com/Martan03/2048)
//! - [futoshiki](https://github.com/Martan03/futoshiki)
//! - [loopover](https://github.com/Martan03/loopover)
//! - [minesweeper](https://github.com/Martan03/minesweeper)
//! - [rsTimer](https://github.com/Martan03/rsTimer)
//! - [tictactoe](https://github.com/Martan03/tictactoe)
//!
//! ## Links
//!
//! - **Author:** [Martan03](https://github.com/Martan03)
//! - **GitHub repository:** [termint](https://github.com/Martan03/termint)
//! - **Package**: [crates.io](https://crates.io/crates/termint)
//! - **Documentation**: [docs.rs](https://docs.rs/termint/latest/termint/)
//! - **Author website:** [martan03.github.io](https://martan03.github.io)
/// Contains enums for foreground, background and more
/// Contains structs for geometry, such as Coords
/// Contains useful macros
/// Contains Term struct
/// Contains widgets (Layout, Block, Span)
pub use Error;
pub use termal;