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
//! # termint
//! Rust library for colored printing and Terminal User Interfaces
//!
//! ## Installation:
//!
//! This library is available on [crates.io](https://crates.io/crates/termint).
//! You can add it to your projects using cargo:
//! ```terminal
//! cargo add termint
//! ```
//!
//! ## Basic example:
//!
//! Printing colored text is really easy, you can do it like this:
//!
//! ```rust
//! # use termint::{
//! #     enums::{bg::Bg, fg::Fg, modifier::Modifier},
//! #     widgets::span::StrSpanExtension,
//! # };
//! println!("{}", "Cyan text".fg(Fg::Cyan));
//! println!("{}", "Cyan text on white background".fg(Fg::Cyan).bg(Bg::White));
//! println!("{}", "Bold red text".fg(Fg::Red).modifier(vec![Modifier::Bold]));
//! println!("{}", "Text with RGB value".fg(Fg::RGB(0, 249, 210)));
//! ```
//! ![image](https://github.com/Martan03/termint/assets/46300167/c906a565-69b5-4664-9db0-ad89ff457cbb)
//!
//! You can see all the colors and modifiers in the
//! [documentation](https://docs.rs/termint/latest/termint/).
//!
//! ## Advanced example:
//!
//! You can also create TUIs using this library. This example shows how you can
//! use Block widget and add children to it and creating Layout:
//!
//! ```rust
//! # use termint::{
//! #     enums::{bg::Bg, fg::Fg},
//! #     geometry::{
//! #         constrain::Constrain, coords::Coords, direction::Direction,
//! #     },
//! #     widgets::{
//! #         block::Block, border::BorderType, span::StrSpanExtension,
//! #         widget::Widget,
//! #     },
//! # };
//! // Creates main block and sets its properties
//! let mut main = Block::new()
//!     .title("Termint".to_span())
//!     .direction(Direction::Horizontal)
//!     .border_type(BorderType::Double);
//!
//! /// Creates block1 and adds span as its child
//! let mut block1 = Block::new().title("Sub block".to_span());
//! let span1 = "I like it!".fg(Fg::Green).bg(Bg::Yellow);
//! block1.add_child(span1, Constrain::Percent(100));
//! /// Adds block1 as child of main block
//! main.add_child(block1, Constrain::Min(0));
//!
//! /// Create block2 and adds span as its child
//! let mut block2 = Block::new().title("Another".to_span());
//! let span2 = "This is really cool, right?".fg(Fg::Blue);
//! block2.add_child(span2, Constrain::Percent(100));
//! /// Adds block2 as child of main block
//! main.add_child(block2, Constrain::Fill);
//!
//! /// Renders the main block which renders all the children
//! main.render(&Coords::new(1, 1), &Coords::new(30, 8));
//! ```
//! ![image](https://github.com/Martan03/termint/assets/46300167/cdd0850b-1952-4c4b-8dec-b49c30d59f6d)
//!
//! ## 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/).
//!
//! ## Technologies
//!
//! Obviously this library was created in Rust, but I also used library called
//! [term-size](https://docs.rs/term_size/latest/term_size/) to get terminal size.
//!
//! ## 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
pub mod enums;
/// Contains structs for geometry, such as Coords
pub mod geometry;
/// Contains useful macros
pub mod macros;
/// Contains Term struct
pub mod term;
/// Contains widgets (Layout, Block, Span)
pub mod widgets;