use std::fmt;
pub enum ForegroundColor {
Black,
Red,
Green,
Yellow,
Blue,
Magenta,
Cyan,
White,
EightBit(u8),
RGB(u8, u8, u8),
Normal,
}
impl fmt::Display for ForegroundColor {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self{
ForegroundColor::Black => write!(f, "\x1b[30m"),
ForegroundColor::Red => write!(f, "\x1b[31m"),
ForegroundColor::Green => write!(f, "\x1b[32m"),
ForegroundColor::Yellow => write!(f, "\x1b[33m"),
ForegroundColor::Blue => write!(f, "\x1b[34m"),
ForegroundColor::Magenta => write!(f, "\x1b[35m"),
ForegroundColor::Cyan => write!(f, "\x1b[36m"),
ForegroundColor::White => write!(f, "\x1b[37m"),
ForegroundColor::EightBit(c) => write!(f, "\x1b[38;5;{}m", c),
ForegroundColor::RGB(r, g, b) => write!(f, "\x1b[38;2;{};{};{}m", r, g, b),
ForegroundColor::Normal => write!(f, "\x1b[39m"),
}
}
}