colourful

Crates.iocolourful
lib.rscolourful
version0.1.0
sourcesrc
created_at2023-08-30 12:15:40.959062
updated_at2023-08-30 12:15:40.959062
descriptionA lightweight, fast, and easy-to-use library for creating coloured strings with ANSI
homepagehttps://github.com/rookieCookies/colourful
repositoryhttps://github.com/rookieCookies/colourful
max_upload_size
id958918
size11,457
*daymare* (rookieCookies)

documentation

https://docs.rs/colourful

README

Colourful

A lightweight, fast, and easy-to-use library for creating coloured strings with ANSI

Ergonomics and speed should not be mutually exclusive, let's look at some examples

println!("'{}'", "bold red on navy blue".red().bold().bg_navy_blue());
println!("'{}'", "green background".bg_colour(Colour::rgb(0, 255, 0,)));
println!("'{}'", "red on green background".colour(Colour::rgb(255, 0, 0)).bg_colour(Colour::rgb(0, 255, 0,)));
println!("'{}'", "bold".bold());
println!("'{}'", "dim".dim());
println!("'{}'", "italic".italic());
println!("'{}'", "underline".underline());
println!("'{}'", "blinking".blinking());
println!("'{}'", "inverse".inverse());
println!("'{}'", "hidden".hidden());
println!("'{}''", "strikethrough".strikethrough());

println!("also works on any type with display {}", Vector3(0.5, 0.3, 1.2).red().blinking());
println!("or debug.. who am i to judge {:#?}", vec!["mhm", "sup", "okay"].strikethrough());

Features

  • No other dependencies

  • Allocation free

  • Blazingly fast

  • Does not emit colours when piping to a file

  • Respects NO_COLOR and FORCE_COLOR

  • Ability to colour and style any type that implements Display or Debug

Usage

  1. Add the dependency to your crate

  2. Import colourful::ColourBrush

  3. You're good to go!

no_std

The base crate relies on reading environment variables to abide by NO_COLOR, and FORCE_COLOR and not print colours when piping. The crate should be able to compile with no_std without you needing to do anything, but these features won't be available

Commit count: 5

cargo fmt