Allow colors to be reset to terminal defaults

This commit is contained in:
Jeremy Soller 2016-07-24 08:23:10 -06:00 committed by GitHub
parent 1d63d09e27
commit ef023ed596
1 changed files with 14 additions and 0 deletions

View File

@ -100,6 +100,20 @@ 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);