extern crate crossterm;
use self::crossterm::style::{Color, style, color};
use self::crossterm::{terminal, Screen};
pub fn paint_foreground() {
let screen = Screen::default();
let mut styledobject = style("Red foreground").with(Color::Red);
styledobject.paint(&screen);
style("Some colored text").with(Color::Blue).on(Color::Black).paint(&screen);
style(format!("Red foreground color : \t {}", "■")).with(Color::Red).paint(&screen);
}
pub fn paint_background() {
let screen = Screen::default();
let mut styledobject = style("Red background color").on(Color::Red);
styledobject.paint(&screen);
style(format!("Red background color : \t {}", "■")).with(Color::Red).paint(&screen);
}
pub fn print_all_foreground_colors() {
let screen = Screen::default();
style(format!("Black : \t\t {} \n", "■")).with(Color::Black).paint(&screen);
style(format!("Red : \t\t {} \n", "■")).with(Color::Red).paint(&screen);
style(format!("Cyan : \t\t {} \n", "■")).with(Color::Cyan).paint(&screen);
style(format!("DarkCyan : \t {} \n", "■")).with(Color::DarkCyan).paint(&screen);
style(format!("DarkRed : \t {} \n", "■")).with(Color::DarkRed).paint(&screen);
style(format!("Green : \t {} \n", "■")).with(Color::Green).paint(&screen);
style(format!("DarkGreen : \t {} \n", "■")).with(Color::DarkGreen).paint(&screen);
style(format!("Blue : \t\t {} \n", "■")).with(Color::Blue).paint(&screen);
style(format!("DarkBlue : \t {} \n", "■")).with(Color::DarkBlue).paint(&screen);
style(format!("Magenta : \t {} \n", "■")).with(Color::Magenta).paint(&screen);
style(format!("DarkMagenta : \t {} \n", "■")).with(Color::DarkMagenta).paint(&screen);
style(format!("Yellow : \t {} \n", "■")).with(Color::Yellow).paint(&screen);
style(format!("DarkYellow : \t {} \n", "■")).with(Color::DarkYellow).paint(&screen);
style(format!("Grey : \t\t {} \n", "■")).with(Color::Grey).paint(&screen);
style(format!("White : \t {} \n", "■")).with(Color::White).paint(&screen);
#[cfg(unix)]
style("RGB color (10,10,10) ").with(Color::Rgb {
r: 10,
g: 10,
b: 10
}).paint(&screen);
#[cfg(unix)]
style("RGB color (10,10,10) ").with(Color::AnsiValue(50)).paint(&screen);
}
pub fn print_all_background_colors() {
let screen = Screen::default();
style(format!("Black : \t {} \n", "■")).on(Color::Black).paint(&screen);
style(format!("Red : \t\t {} \n", "■")).on(Color::Red).paint(&screen);
style(format!("Cyan : \t\t {} \n", "■")).on(Color::Cyan).paint(&screen);
style(format!("DarkCyan : \t {} \n", "■")).on(Color::DarkCyan).paint(&screen);
style(format!("DarkRed : \t {} \n", "■")).on(Color::DarkRed).paint(&screen);
style(format!("Green : \t {} \n", "■")).on(Color::Green).paint(&screen);
style(format!("DarkGreen : \t {} \n", "■")).on(Color::DarkGreen).paint(&screen);
style(format!("Blue : \t\t {} \n", "■")).on(Color::Blue).paint(&screen);
style(format!("DarkBlue : \t {} \n", "■")).on(Color::DarkBlue).paint(&screen);
style(format!("Magenta : \t {} \n", "■")).on(Color::Magenta).paint(&screen);
style(format!("DarkMagenta : \t {} \n", "■")).on(Color::DarkMagenta).paint(&screen);
style(format!("Yellow : \t {} \n", "■")).on(Color::Yellow).paint(&screen);
style(format!("DarkYellow : \t {} \n", "■")).on(Color::DarkYellow).paint(&screen);
style(format!("Grey : \t\t {} \n", "■")).on(Color::Grey).paint(&screen);
style(format!("White : \t {} \n", "■")).on(Color::White).paint(&screen);
#[cfg(unix)]
style("RGB color (10,10,10) ").on(Color::Rgb {
r: 10,
g: 10,
b: 10
}).paint(&screen);
#[cfg(unix)]
style("RGB color (10,10,10) ").on(Color::AnsiValue(50)).paint(&screen);
}
#[cfg(unix)]
pub fn print_font_with_attributes() {
let screen = Screen::default();
style("Normal text").paint(&screen);
style("Bold text").bold().paint(&screen);
style("Italic text").italic().paint(&screen);
style("Slow blinking text").slow_blink().paint(&screen);
style("Rapid blinking text").rapid_blink().paint(&screen);
style("Hidden text").hidden().paint(&screen);
style("Underlined text").underlined().paint(&screen);
style("Reversed text").reverse().paint(&screen);
style("Dim text").dim().paint(&screen);
style("Crossed out font").crossed_out().paint(&screen);
}
#[cfg(unix)]
pub fn print_supported_colors() {
let screen = Screen::default();
let count = color(&screen)
.get_available_color_count()
.unwrap();
for i in 0..count {
style(format!("White : \t {}", i)).on(Color::AnsiValue(i as u8)).paint(&screen);
}
}