From 7d8a0fdb7dafa5dfca003f5418119f0aaaac1484 Mon Sep 17 00:00:00 2001 From: Kevin Ballard Date: Wed, 10 Jul 2013 18:26:04 -0700 Subject: [PATCH] Give term.fg() and term.bg() a bool return value --- src/libextra/term.rs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/libextra/term.rs b/src/libextra/term.rs index cd226e2ad326..1740f4d1ecc1 100644 --- a/src/libextra/term.rs +++ b/src/libextra/term.rs @@ -88,33 +88,41 @@ impl Terminal { /// /// If the color is a bright color, but the terminal only supports 8 colors, /// the corresponding normal color will be used instead. - pub fn fg(&self, color: color::Color) { + /// + /// Returns true if the color was set, false otherwise. + pub fn fg(&self, color: color::Color) -> bool { let color = self.dim_if_necessary(color); if self.num_colors > color { let s = expand(*self.ti.strings.find_equiv(&("setaf")).unwrap(), [Number(color as int)], &mut Variables::new()); if s.is_ok() { self.out.write(s.unwrap()); + return true } else { warn!("%s", s.unwrap_err()); } } + false } /// Sets the background color to the given color. /// /// If the color is a bright color, but the terminal only supports 8 colors, /// the corresponding normal color will be used instead. - pub fn bg(&self, color: color::Color) { + /// + /// Rturns true if the color was set, false otherwise. + pub fn bg(&self, color: color::Color) -> bool { let color = self.dim_if_necessary(color); if self.num_colors > color { let s = expand(*self.ti.strings.find_equiv(&("setab")).unwrap(), [Number(color as int)], &mut Variables::new()); if s.is_ok() { self.out.write(s.unwrap()); + return true } else { warn!("%s", s.unwrap_err()); } } + false } pub fn reset(&self) { let mut vars = Variables::new(); @@ -144,10 +152,12 @@ impl Terminal { return Ok(Terminal {out: out, num_colors: 0}); } - pub fn fg(&self, _color: color::Color) { + pub fn fg(&self, _color: color::Color) -> bool { + false } - pub fn bg(&self, _color: color::Color) { + pub fn bg(&self, _color: color::Color) -> bool { + false } pub fn reset(&self) {