use std::fmt;
pub enum BackgroundColor {
Black,
Red,
Green,
Yellow,
Blue,
Magenta,
Cyan,
White,
EightBit(u8),
RGB(u8, u8, u8),
Normal,
}
impl fmt::Display for BackgroundColor {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self{
BackgroundColor::Black => write!(f, "\x1b[40m"),
BackgroundColor::Red => write!(f, "\x1b[41m"),
BackgroundColor::Green => write!(f, "\x1b[42m"),
BackgroundColor::Yellow => write!(f, "\x1b[43m"),
BackgroundColor::Blue => write!(f, "\x1b[44m"),
BackgroundColor::Magenta => write!(f, "\x1b[45m"),
BackgroundColor::Cyan => write!(f, "\x1b[46m"),
BackgroundColor::White => write!(f, "\x1b[47m"),
BackgroundColor::EightBit(c) => write!(f, "\x1b[48;5;{}m", c),
BackgroundColor::RGB(r, g, b) => write!(f, "\x1b[48;2;{};{};{}m", r, g, b),
BackgroundColor::Normal => write!(f, "\x1b[49m"),
}
}
}