termint

Crates.iotermint
lib.rstermint
version0.6.0
created_at2024-01-27 14:57:39.062358+00
updated_at2025-09-07 17:38:25.167428+00
descriptionLibrary for colored printing and Terminal User Interfaces
homepage
repositoryhttps://github.com/Martan03/termint
max_upload_size
id1116761
size362,589
Martin Slezák (Martan03)

documentation

https://docs.rs/termint/latest/termint/

README

termint

Crates.io Version docs.rs Crates.io Total Downloads

Rust library for colored printing and Terminal User Interfaces

Table of Contents

How to get it

This crate is available on crates.io.

With cargo

cargo add termint

In Cargo.toml

[dependencies]
termint = "0.6.0"

Features

  • serde: Enables serialization and deserialization of some structs.
  • all: Enables all features.

Examples

Printing colored text

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)));

image

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");

Terminal User Interface (TUI)

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)?;

image

TUI examples

image

image

image

Usage

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.

Projects

Here is a list of some projects using termint:

Links

Commit count: 286

cargo fmt