couleur

Crates.iocouleur
lib.rscouleur
version0.1.0
sourcesrc
created_at2022-06-28 19:41:43.54443
updated_at2022-06-28 19:41:43.54443
descriptionAdd the ablity to print colored text to the console
homepage
repository
max_upload_size
id615003
size17,308
(JurassicBunny)

documentation

README

couleur

Colored and or styled text that may be printed to the console.

Contains the text to be printed, the color selected, and Styles added. To initialize a ColorTxt, one only needs to call either coloriser or styliser on a String or &str.

Examples

// import trait and structs
use couleur::{Couleur, Colors, Styles};

fn main() {
    // define ColorTxt with color and add style
    let color_text = "Hello, World!".coloriser(Colors::Red)
                                    .add_style(Styles::Bold);

    // define ColorTxt with style and add color
    let style_text = "Hello, World!".styliser(Styles::Bold)
                                    .edit_color(Colors::Red);

    // color_text and style_text will be the same
    assert_eq!(color_text, style_text);
}

Color or style may be omitted. In such a case, the omitted field will resort to the default i.e. uncolored text or no style.

Multiple styles can be added to a ColorTxt:

# use couleur::{Couleur, Colors, Styles};
let text = "Hello, World!".coloriser(Colors::Blue)
                          .add_style(Styles::Bold)
                          .add_style(Styles::Underline);

In the above example, the styles Bold and Underline are added to a UniqueVec<Styles> maintained by the ColorTxt. This insures that each style is only accounted for one time.

Commit count: 0

cargo fmt