@@ -88,33 +88,41 @@ impl Terminal {
88
88
///
89
89
/// If the color is a bright color, but the terminal only supports 8 colors,
90
90
/// 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 {
92
94
let color = self . dim_if_necessary ( color) ;
93
95
if self . num_colors > color {
94
96
let s = expand ( * self . ti . strings . find_equiv ( & ( "setaf" ) ) . unwrap ( ) ,
95
97
[ Number ( color as int ) ] , & mut Variables :: new ( ) ) ;
96
98
if s. is_ok ( ) {
97
99
self . out . write ( s. unwrap ( ) ) ;
100
+ return true
98
101
} else {
99
102
warn ! ( "%s" , s. unwrap_err( ) ) ;
100
103
}
101
104
}
105
+ false
102
106
}
103
107
/// Sets the background color to the given color.
104
108
///
105
109
/// If the color is a bright color, but the terminal only supports 8 colors,
106
110
/// 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 {
108
114
let color = self . dim_if_necessary ( color) ;
109
115
if self . num_colors > color {
110
116
let s = expand ( * self . ti . strings . find_equiv ( & ( "setab" ) ) . unwrap ( ) ,
111
117
[ Number ( color as int ) ] , & mut Variables :: new ( ) ) ;
112
118
if s. is_ok ( ) {
113
119
self . out . write ( s. unwrap ( ) ) ;
120
+ return true
114
121
} else {
115
122
warn ! ( "%s" , s. unwrap_err( ) ) ;
116
123
}
117
124
}
125
+ false
118
126
}
119
127
pub fn reset( & self ) {
120
128
let mut vars = Variables :: new ( ) ;
@@ -144,10 +152,12 @@ impl Terminal {
144
152
return Ok ( Terminal { out : out, num_colors : 0 } ) ;
145
153
}
146
154
147
- pub fn fg ( & self , _color : color:: Color ) {
155
+ pub fn fg ( & self , _color : color:: Color ) -> bool {
156
+ false
148
157
}
149
158
150
- pub fn bg ( & self , _color : color:: Color ) {
159
+ pub fn bg ( & self , _color : color:: Color ) -> bool {
160
+ false
151
161
}
152
162
153
163
pub fn reset ( & self ) {
0 commit comments