11 unstable releases

0.6.1 Jul 9, 2024
0.5.1 Sep 16, 2023
0.5.0 Jul 19, 2023
0.2.0 Feb 19, 2023

#876 in Command-line interface

41 downloads per month

GPL-3.0 license

22KB
593 lines

hel-colored

ANSI string colorizer and styler

Features

  • Lazy (no-alloc, no-copy, until needed, e.g. to_string called)
  • Made with performance in mind
  • Only RGB(TrueColor) support (no default CLI colors)
  • No nested checks by default, which leads up to 2x performance.

Examples

Simply by

"Hello World!".bold().blue().underline();

Nested with "nested" feature

cargo add hel-colored -F nested
let blue_text: ANSIString<&str> = "blue text".blue();
let green_blue_green_text: ANSIString<String> = format!("Green {blue_text} wrapping").green();
// Better to call `to_string` above
println!("{green_blue_green_text}");

Or with builder

let builder: ANSIStringBuilder = ANSIStringBuilder::new().bold().underline().orange();
let str1 = builder.build("Hello");
let str2 = builder.build("World!");
println!("{str1}, {str2}")

How to install

cargo add hel-colored

lib.rs:

This crate provides a fast and easy way to color and style string using ANSI escape sequences Repo: https://github.com/Hellaeh/hel-colored

No runtime deps