@@ -43,8 +43,6 @@ pub static color_bright_magenta: u8 = 13u8;
43
43
pub static color_bright_cyan: u8 = 14u8 ;
44
44
pub static color_bright_white: u8 = 15u8 ;
45
45
46
- pub fn esc ( writer : @io:: Writer ) { writer. write ( [ 0x1bu8 , '[' as u8 ] ) ; }
47
-
48
46
pub struct Terminal {
49
47
color_supported : bool ,
50
48
priv out: @io:: Writer ,
@@ -75,12 +73,20 @@ pub impl Terminal {
75
73
return Ok ( Terminal { out : out, ti : inf, color_supported : cs} ) ;
76
74
}
77
75
fn fg ( & self , color : u8 ) {
78
- self . out . write ( expand ( * self . ti . strings . find_equiv ( & ( "setaf" ) ) . unwrap ( ) , [ Number ( color as int ) ] , [ ] , [ ] ) ) ;
76
+ if self . color_supported {
77
+ self . out . write ( expand ( * self . ti . strings . find_equiv ( & ( "setaf" ) ) . unwrap ( ) ,
78
+ [ Number ( color as int ) ] , [ ] , [ ] ) ) ;
79
+ }
79
80
}
80
81
fn bg ( & self , color : u8 ) {
81
- self . out . write ( expand ( * self . ti . strings . find_equiv ( & ( "setab" ) ) . unwrap ( ) , [ Number ( color as int ) ] , [ ] , [ ] ) ) ;
82
+ if self . color_supported {
83
+ self . out . write ( expand ( * self . ti . strings . find_equiv ( & ( "setab" ) ) . unwrap ( ) ,
84
+ [ Number ( color as int ) ] , [ ] , [ ] ) ) ;
85
+ }
82
86
}
83
87
fn reset ( & self ) {
84
- self . out . write ( expand ( * self . ti . strings . find_equiv ( & ( "op" ) ) . unwrap ( ) , [ ] , [ ] , [ ] ) ) ;
88
+ if self . color_supported {
89
+ self . out . write ( expand ( * self . ti . strings . find_equiv ( & ( "op" ) ) . unwrap ( ) , [ ] , [ ] , [ ] ) ) ;
90
+ }
85
91
}
86
92
}
0 commit comments