Merge pull request #34 from jackpot51/patch-2

Allow colors to be reset to terminal defaults
This commit is contained in:
ticki 2016-07-24 19:54:50 +02:00 committed by GitHub
commit c43f54accd
1 changed files with 15 additions and 0 deletions

View File

@ -100,6 +100,21 @@ impl Color for Rgb {
}
}
/// Reset colors to defaults.
pub struct Reset;
impl Color for Reset {
#[inline]
fn write_fg(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, csi!("39m"))
}
#[inline]
fn write_bg(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, csi!("49m"))
}
}
/// A foreground color.
pub struct Fg<C: Color>(pub C);