Crate ino_color

Crate ino_color 

Source
Expand description

Coloring the terminal output.

§Basic Usage

// This's the trait that adds coloring methods.
use ino_color::InoColor;

// These two modules contain predefined colors and styles.
// As a personal preferrence, wildcard import should be avoided,
// even though doing so makes the function call looks funnier.
use ino_color::fg;
use ino_color::style;

// The most basic usage
println!(
    "{}", "Hello Fancy".fg::<fg::Yellow>()
);

// It's also chainable!
println!(
    "{}", "Savoy blue".fg::<fg::Blue>().style::<style::Italic>()
);

// In fact, anything which implements `std::fmt` traits can be colored.
println!( "{:?}", vec![123].fg::<fg::Green>() );
println!( "{:X}", 123.fg::<fg::Green>() );

§Convenient Macros

use ino_color::cprintln;
use ino_color::ceprintln;
use ino_color::fg::Blue;
use ino_color::fg::Green;

// The first parameter is the foreground color,
// and the remainings are idetical to the corresponding
// print macros from std.
cprintln!(Blue, "The message is blue");

let elems = vec![1, 2, 3, 4];
ceprintln!(Green, "{elems:?}");

Re-exports§

pub use has_colors::HasColors;

Modules§

fg
Named 16 foreground colors.
has_colors
Check whether ANSI color should be enabled.
style
Commonly used style attributes.

Macros§

ceprintln
Print with color, wraps std::eprintln!
cprintln
Print with color, wraps std::println!

Structs§

Painter
Add colors to some object. The color and style information is embedded in its type, cool!

Traits§

AnsiSgr
An attribute in the ANSI SGR list.
BG
The corresponding attribute is for background color.
FG
The corresponding attribute is for foreground color.
InoColor
Have methods for coloring things.
Style
The corresponding attribute is for attributes which mainly affects the style of output, such as italic or bold.