Crates.io | chromaterm |
lib.rs | chromaterm |
version | 0.1.1 |
created_at | 2025-04-22 23:59:20.27114+00 |
updated_at | 2025-05-20 22:45:02.823747+00 |
description | Yet another crate for terminal colors. |
homepage | |
repository | https://github.com/spenserblack/chromaterm.git |
max_upload_size | |
id | 1644845 |
size | 89,445 |
chromaterm
Yet another crate for terminal colors.
String
use chromaterm::prelude::*;
// This crate is configurable, but requires some initialization.
chromaterm::config::use_default_color_support();
chromaterm::config::convert_to_supported(true);
// # Colorization
println!("Hello, {}!", "World".green().on_blue().bold());
Colorization is available on &str
and all types that implement Deref<Target=str>
(like String
).
Check out the examples for more usage.
There are some limitations that you might run into, compared to other libraries.
The types are much more strict compared to some libraries like colored, due to the heavy use of
generics. "".red().on_green()
is a different type than "".on_green().red()
.
In colored's implementation, "red or green".red().green()
will set the text to the color
green. In this crate, "red or green".red().green()
will be red. This is because
colorization and styling is implemented by wrapping an inner type.
This isn't the exact implementation, but a handy visualization is that
"red or green".red().green()
is equivalent to Green(Red("red or green"))
.