#[macro_use]
extern crate crossterm_utils;
#[cfg(windows)]
extern crate crossterm_winapi;
#[macro_use]
mod macros;
mod color;
mod enums;
pub mod objectstyle;
pub mod styledobject;
mod traits;
mod ansi_color;
#[cfg(windows)]
mod winapi_color;
use self::ansi_color::AnsiColor;
#[cfg(windows)]
use self::winapi_color::WinApiColor;
use std::fmt::Display;
pub use self::color::{color, TerminalColor};
pub use self::enums::{Attribute, Color, Colored};
pub use self::objectstyle::ObjectStyle;
pub use self::styledobject::StyledObject;
pub use self::traits::{Colorize, Styler};
use crossterm_utils::Result;
trait ITerminalColor {
fn set_fg(&self, fg_color: Color) -> Result<()>;
fn set_bg(&self, fg_color: Color) -> Result<()>;
fn reset(&self) -> Result<()>;
fn color_value(&self, cored: Colored) -> String;
}
pub fn style<'a, D: 'a>(val: D) -> StyledObject<D>
where
D: Display,
{
ObjectStyle::new().apply_to(val)
}
impl Colorize<&'static str> for &'static str {
def_str_color!(fg_color: black => Color::Black);
def_str_color!(fg_color: dark_grey => Color::DarkGrey);
def_str_color!(fg_color: red => Color::Red);
def_str_color!(fg_color: dark_red => Color::DarkRed);
def_str_color!(fg_color: green => Color::Green);
def_str_color!(fg_color: dark_green => Color::DarkGreen);
def_str_color!(fg_color: yellow => Color::Yellow);
def_str_color!(fg_color: dark_yellow => Color::DarkYellow);
def_str_color!(fg_color: blue => Color::Blue);
def_str_color!(fg_color: dark_blue => Color::DarkBlue);
def_str_color!(fg_color: magenta => Color::Magenta);
def_str_color!(fg_color: dark_magenta => Color::DarkMagenta);
def_str_color!(fg_color: cyan => Color::Cyan);
def_str_color!(fg_color: dark_cyan => Color::DarkCyan);
def_str_color!(fg_color: white => Color::White);
def_str_color!(fg_color: grey => Color::Grey);
def_str_color!(bg_color: on_black => Color::Black);
def_str_color!(bg_color: on_dark_grey => Color::DarkGrey);
def_str_color!(bg_color: on_red => Color::Red);
def_str_color!(bg_color: on_dark_red => Color::DarkRed);
def_str_color!(bg_color: on_green => Color::Green);
def_str_color!(bg_color: on_dark_green => Color::DarkGreen);
def_str_color!(bg_color: on_yellow => Color::Yellow);
def_str_color!(bg_color: on_dark_yellow => Color::DarkYellow);
def_str_color!(bg_color: on_blue => Color::Blue);
def_str_color!(bg_color: on_dark_blue => Color::DarkBlue);
def_str_color!(bg_color: on_magenta => Color::Magenta);
def_str_color!(bg_color: on_dark_magenta => Color::DarkMagenta);
def_str_color!(bg_color: on_cyan => Color::Cyan);
def_str_color!(bg_color: on_dark_cyan => Color::DarkCyan);
def_str_color!(bg_color: on_white => Color::White);
def_str_color!(bg_color: on_grey => Color::Grey);
}
impl Styler<&'static str> for &'static str {
def_str_attr!(reset => Attribute::Reset);
def_str_attr!(bold => Attribute::Bold);
def_str_attr!(underlined => Attribute::Underlined);
def_str_attr!(reverse => Attribute::Reverse);
def_str_attr!(dim => Attribute::Dim);
def_str_attr!(italic => Attribute::Italic);
def_str_attr!(negative => Attribute::Reverse);
def_str_attr!(slow_blink => Attribute::SlowBlink);
def_str_attr!(rapid_blink => Attribute::RapidBlink);
def_str_attr!(hidden => Attribute::Hidden);
def_str_attr!(crossed_out => Attribute::CrossedOut);
}