term-painter 0.2.1

Coloring and formatting terminal output
docs.rs failed to build term-painter-0.2.1
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build: term-painter-0.4.0

Coloring terminal ouput

Build Status crates.io version GitHub license

Documentation

term-painter is a Rust library for coloring and formatting terminal output. It provides easy ways to format various things and uses the crate rust-lang/term to do the actual formatting. Example:

println!("{} | {} | {} | {} | {}",
    Red.bg(Green).bold().paint("Red-Green-Bold"),
    Blue.paint("Blue"),
    Blue.bold().paint("BlueBold"),
    Blue.bg(Magenta).paint("BlueMagentaBG"),
    Plain.underline().paint("Underline"));

Red.with(|| {
    print!("JustRed");
    Bold.with(|| {
        print!(" BoldRed {} BoldRed ", Underline.paint("Underline"));
    });
    print!("JustRed ");

    print!("{}", Blue.paint("Blue (overwrite) "));
    Green.with(|| {
        println!("Green (overwrite)");
    });
});

alt text

It's easy to use and integrates well with println!/print!. The main design goal was to make it simple. This has one performance disadvantage: It will often reset the terminal style after each printing operation. But performance isn't usually hugely important when printing on the terminal, so simplicity was more important for the design of this library.

More examples here (examples/main.rs) or in the Documentation.

Usage

Just add extern crate term_painter; in your crate root and the dependency in your Cargo.toml file:

[dependencies]
term-painter = "*"

Collaboration

Yes please! If you find a bug, have any feature request or anything else: Please open a issue or create a pull request.

Thanks

I've got some design ideas from rust-ansi-term. I decided to make my own crate though, since my goals were too different from ansi-term.