Crate colorize [] [src]

Terminal color using ansi escape character for Rust.

extern mod colorize;
// Import the trait implemented for &'static str and ~str
use colorize::AnsiColor;
// Import the colors for the global
use colorize::{BrightRed, Blue};

pub fn main() {
    // Set some global colors
    colorize::global_fg(BrightRed);
    colorize::global_bg(Blue);
    // ^~~~ These settings are reset to default at the end.

    // You can use specific colors or style on a given str,
    // the globals colors are restored after !

    // Write a green underlined text on a yellow background !
    println!("{}", "Hello World !".green().underline().yellowb());

    // Use bright or normal colors
    println!("{}", "Bright Green foreground and Magenta background !"
                   .b_green()
                   .magentab());
}

Enums

BgColor
Color

Ansi color to set the global foreground / background color

Style

Traits

AnsiColor

Methods extension to colorize the text contained in a string using a simple mathod call

Functions

global_bg

Set a custom global background color

global_fg

Set a custom global foreground color

reset

Reset the background and foreground color to the defaults colors