From ef023ed5969c8cc8dbe69d6b646ad9c7d07b4065 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Sun, 24 Jul 2016 08:23:10 -0600 Subject: [PATCH 1/2] Allow colors to be reset to terminal defaults --- src/color.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/color.rs b/src/color.rs index 60e2687..469e945 100644 --- a/src/color.rs +++ b/src/color.rs @@ -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(pub C); From b81bcc6749ad236f1929236640b526fcdae46984 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Sun, 24 Jul 2016 08:24:49 -0600 Subject: [PATCH 2/2] Fix formatting --- src/color.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/color.rs b/src/color.rs index 469e945..e4f781d 100644 --- a/src/color.rs +++ b/src/color.rs @@ -103,7 +103,8 @@ impl Color for Rgb { /// Reset colors to defaults. pub struct Reset; -impl Color for Reset {#[inline] +impl Color for Reset { + #[inline] fn write_fg(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, csi!("39m")) }