about summary refs log tree commit diff
path: root/src/libextra
diff options
context:
space:
mode:
authorKevin Ballard <kevin@sb.org>2013-07-10 18:26:04 -0700
committerKevin Ballard <kevin@sb.org>2013-07-14 14:37:29 -0700
commit7d8a0fdb7dafa5dfca003f5418119f0aaaac1484 (patch)
tree58dba5a859d6bdc823c35a9362b5a1f60bc39e63 /src/libextra
parent0cb1ac0f9f7bf98ea8ab5ccbd6ef319decc41a72 (diff)
downloadrust-7d8a0fdb7dafa5dfca003f5418119f0aaaac1484.tar.gz
rust-7d8a0fdb7dafa5dfca003f5418119f0aaaac1484.zip
Give term.fg() and term.bg() a bool return value
Diffstat (limited to 'src/libextra')
-rw-r--r--src/libextra/term.rs18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/libextra/term.rs b/src/libextra/term.rs
index cd226e2ad32..1740f4d1ecc 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) {