#ansi #string #ansi-colors #color #style

nightly hel-colored

ANSI string colorizer and styler

9 releases (4 breaking)

0.5.1 Sep 16, 2023
0.5.0 Jul 19, 2023
0.4.4 Jun 16, 2023
0.4.0 Apr 13, 2023
0.1.0 Feb 17, 2023

#1869 in Algorithms

44 downloads per month

GPL-3.0 license

21KB
572 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