Skip to content

Commit 7d8a0fd

Browse files
committed
Give term.fg() and term.bg() a bool return value
1 parent 0cb1ac0 commit 7d8a0fd

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/libextra/term.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,33 +88,41 @@ impl Terminal {
8888
///
8989
/// If the color is a bright color, but the terminal only supports 8 colors,
9090
/// the corresponding normal color will be used instead.
91-
pub fn fg(&self, color: color::Color) {
91+
///
92+
/// Returns true if the color was set, false otherwise.
93+
pub fn fg(&self, color: color::Color) -> bool {
9294
let color = self.dim_if_necessary(color);
9395
if self.num_colors > color {
9496
let s = expand(*self.ti.strings.find_equiv(&("setaf")).unwrap(),
9597
[Number(color as int)], &mut Variables::new());
9698
if s.is_ok() {
9799
self.out.write(s.unwrap());
100+
return true
98101
} else {
99102
warn!("%s", s.unwrap_err());
100103
}
101104
}
105+
false
102106
}
103107
/// Sets the background color to the given color.
104108
///
105109
/// If the color is a bright color, but the terminal only supports 8 colors,
106110
/// the corresponding normal color will be used instead.
107-
pub fn bg(&self, color: color::Color) {
111+
///
112+
/// Rturns true if the color was set, false otherwise.
113+
pub fn bg(&self, color: color::Color) -> bool {
108114
let color = self.dim_if_necessary(color);
109115
if self.num_colors > color {
110116
let s = expand(*self.ti.strings.find_equiv(&("setab")).unwrap(),
111117
[Number(color as int)], &mut Variables::new());
112118
if s.is_ok() {
113119
self.out.write(s.unwrap());
120+
return true
114121
} else {
115122
warn!("%s", s.unwrap_err());
116123
}
117124
}
125+
false
118126
}
119127
pub fn reset(&self) {
120128
let mut vars = Variables::new();
@@ -144,10 +152,12 @@ impl Terminal {
144152
return Ok(Terminal {out: out, num_colors: 0});
145153
}
146154

147-
pub fn fg(&self, _color: color::Color) {
155+
pub fn fg(&self, _color: color::Color) -> bool {
156+
false
148157
}
149158

150-
pub fn bg(&self, _color: color::Color) {
159+
pub fn bg(&self, _color: color::Color) -> bool {
160+
false
151161
}
152162

153163
pub fn reset(&self) {

0 commit comments

Comments
 (0)