File tree Expand file tree Collapse file tree 1 file changed +14
-4
lines changed
Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -246,14 +246,24 @@ impl<T: Instantiable + Isatty + io::Write> io::Write for Terminal<T> {
246246 }
247247}
248248
249+ macro_rules! swallow_unsupported {
250+ ( $call: expr ) => { {
251+ use term:: Error :: * ;
252+ match $call {
253+ Ok ( ( ) ) | Err ( ColorOutOfRange ) | Err ( NotSupported ) => Ok ( ( ) ) ,
254+ Err ( e) => Err ( e) ,
255+ }
256+ } } ;
257+ }
258+
249259impl < T : Instantiable + Isatty + io:: Write > Terminal < T > {
250260 pub fn fg ( & mut self , color : color:: Color ) -> Result < ( ) , term:: Error > {
251261 if !T :: isatty ( ) {
252262 return Ok ( ( ) ) ;
253263 }
254264
255265 if let Some ( ref mut t) = self . 0 {
256- t. fg ( color)
266+ swallow_unsupported ! ( t. fg( color) )
257267 } else {
258268 Ok ( ( ) )
259269 }
@@ -268,8 +278,8 @@ impl<T: Instantiable + Isatty + io::Write> Terminal<T> {
268278 if let Err ( e) = t. attr ( attr) {
269279 // If `attr` is not supported, try to emulate it
270280 match attr {
271- Attr :: Bold => t. fg ( color:: BRIGHT_WHITE ) ,
272- _ => Err ( e) ,
281+ Attr :: Bold => swallow_unsupported ! ( t. fg( color:: BRIGHT_WHITE ) ) ,
282+ _ => swallow_unsupported ! ( Err ( e) ) ,
273283 }
274284 } else {
275285 Ok ( ( ) )
@@ -285,7 +295,7 @@ impl<T: Instantiable + Isatty + io::Write> Terminal<T> {
285295 }
286296
287297 if let Some ( ref mut t) = self . 0 {
288- t. reset ( )
298+ swallow_unsupported ! ( t. reset( ) )
289299 } else {
290300 Ok ( ( ) )
291301 }
You can’t perform that action at this time.
0 commit comments