Crates.io | termint |
lib.rs | termint |
version | 0.6.0 |
created_at | 2024-01-27 14:57:39.062358+00 |
updated_at | 2025-09-07 17:38:25.167428+00 |
description | Library for colored printing and Terminal User Interfaces |
homepage | |
repository | https://github.com/Martan03/termint |
max_upload_size | |
id | 1116761 |
size | 362,589 |
Rust library for colored printing and Terminal User Interfaces
This crate is available on crates.io.
cargo add termint
[dependencies]
termint = "0.6.0"
serde
: Enables serialization and deserialization of some structs.all
: Enables all features.Printing colored text is really easy, you can do it by using any Text
widget. Here is an example of using Span
widget:
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:
printcln!("{'yellow italic}Yellow Italic text{'reset}");
printcln!("{'y i}{}{'_}", "Yellow Italic text");
printcln!("{'#dd0 i}{}{'_}", "Custom Yellow Italic text");
The main purpose of this crate is to create Terminal User Interfaces (TUIs).
Example below shows minimal example of creating a TUI using Block
widget
and rendering it using Term
. You can find more examples in the examples
directory of this repository.
// Creates main block and sets its properties
let mut main = Block::horizontal()
.title("Termint")
.border_type(BorderType::Double);
// Creates block1 and adds span as its child
let mut block1 = Block::vertical().title("Sub block");
let span1 = "I like it!".fg(Color::Green).bg(Color::Yellow);
block1.push(span1, Constraint::Percent(100));
// Adds block1 as child of main block
main.push(block1, Constraint::Min(0));
// Creates block2 and adds span as its child
let mut block2 = Block::vertical().title("Another");
let span2 = "This is really cool, right?".fg(Color::Blue);
block2.push(span2, Constraint::Percent(100));
// Adds block2 as child of main block
main.push(block2, Constraint::Fill(1));
// Renders the main block which renders all the children using Buffer
let mut term = Term::new();
term.render(main)?;
Code blocks above are just examples of the usage. To see more about functions, Widgets and more, please visit the documentation.
You can also check the examples
directory of this repository for more
examples of how to use this crate for creating TUIs.
Here is a list of some projects using termint: