Crate color_please

Crate color_please 

Source
Expand description

§color_please

A simple library for coloring terminal and terminal text graphics control.
It uses ANSI control sequences for setting colors and effects, tested only on MacOS.
Some of the features in effect controls may not be supported in some systems or some terminal emulators.

§Usage

§Coloring Foreground and Background

use color_please::*;
fn main(){
    // Setting Foreground color and background color simply.
    set_fg(Color::Red);
    println!("This text is red.");
    set_bg(Color::Yellow);
    println!("And now the background is yellow.");
    // Bright Colors
    set_fg(Color::BrightGreen);
    println!("Why don't use bright green and look like a hacker in a film?");
    set_bg(Color::BrightCyan);
    println!("Walls of my terminal is my favourite color!");
    // Using 256 Colors
    set_fg(Color::Color256(123));
    println!("This text is color 123 of 256 colors.");
    // Using RGB
    set_bg(Color::ColorRGB(0, 200, 255));
    println!("The background is RGB(0,200,255).");
    // Reset the colors
    reset_fg();
    reset_bg();
}

§Graphics Control

use color_please::*;
fn main(){
    // Making text effects on
    bold();
    faint();
    italic();
    underline();
    // To blinking
    blink();
    // Or not to blinking
    blink_off();
    // But this time faster
    fast_blink();
    // Ok, blinking sucks
    blink_off();
    // Reverse the foreground with background and make your eyes dazzle
    reverse();
    // Let's return to our black terminal, white theme sucks
    reverse_off();
    // Make texts invisible and surprise your friend
    invisible();
    println!("You can't see this.");
    // No need to close and open a new terminal
    invisible_off();
    println!("But you can see this.");
    // Strike the last item on your to do list
    strike();
    println!("Add color_please into the dependencies.");
    // Close striking
    strike_off();
    // Turn off the text effects
    bold_and_faint_off();
    underline_off();
    italic_off();
    // Or turn all of the effects and colors off at the same time
    reset_all();
}

§LICENSE

This project is distributed under MIT license.

Enums§

Color
The enum includes the default 4-bit colors, bright colors, 256 colors and RGB colors.

Functions§

blink
Turns on the blink effect.
blink_off
Turns the blink/rapid blink effect off.
bold
Sets the terminal font bold.
bold_and_faint_off
Turns the bold and faint effects off.
faint
Makes the faint effect, decreases the density of colors.
fast_blink
Turns on the rapid blink effect.
invisible
Makes the text invisible.
invisible_off
Makes the text appear if invisible.
italic
Makes the terminal font italic.
italic_off
Turns off italic font.
make_bold
Makes the text given bold.
make_colored_bg
Returns the given text’s background dyed with the color given.
make_colored_fg
Returns the given text’s foreground dyed with color given.
make_faint
Applies the faint effect on the text given.
make_invisible
Makes the text given invisible.
make_italic
Makes the text given italic.
make_reversed
Switches the background and foreground colors of the text given.
make_striked
Makes the text given striked.
make_underlined
Makes the text given underlined.
reset_all
Resets all the graphical effects and colorings.
reset_bg
Resets the background color to default.
reset_fg
Resets the foreground color to default.
reverse
Switches the background color and the foreground color.
reverse_off
Turns the reverse effect off.
set_bg
Sets the background color of the terminal.
set_fg
Sets the foreground color of the terminal.
strike
Strikes the text.
strike_off
Turns off the strike effect.
underline
Makes the text underlined.
underline_off
Turns off the underlining.