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

nightly hel-colored

ANSI string colorizer and styler

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

#542 in Algorithms

Download history 44/week @ 2024-04-01 178/week @ 2024-05-27 15/week @ 2024-06-03 6/week @ 2024-06-10 29/week @ 2024-07-01 119/week @ 2024-07-08

149 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