File tree 1 file changed +19
-2
lines changed
1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ use codemap;
13
13
14
14
use std:: io;
15
15
use std:: uint;
16
+ use std:: local_data;
16
17
use extra:: term;
17
18
18
19
pub type Emitter = @fn ( cmsp : Option < ( @codemap:: CodeMap , span ) > ,
@@ -187,13 +188,29 @@ fn diagnosticcolor(lvl: level) -> term::color::Color {
187
188
}
188
189
189
190
fn print_maybe_styled ( msg : & str , color : term:: attr:: Attr ) {
191
+ #[ cfg( not( stage0) ) ]
192
+ static tls_terminal: local_data:: Key < @Option < term:: Terminal > > = & local_data:: Key ;
193
+ #[ cfg( stage0) ]
194
+ fn tls_terminal ( _: @Option < term:: Terminal > ) { }
195
+
190
196
let stderr = io:: stderr ( ) ;
191
197
192
198
if stderr. get_type ( ) == io:: Screen {
193
- let t = term:: Terminal :: new ( stderr) ;
199
+ let t = match local_data:: get ( tls_terminal, |v| v. map_consume ( |& k|k) ) {
200
+ None => {
201
+ let t = term:: Terminal :: new ( stderr) ;
202
+ let tls = @match t {
203
+ Ok ( t) => Some ( t) ,
204
+ Err ( _) => None
205
+ } ;
206
+ local_data:: set ( tls_terminal, tls) ;
207
+ & * tls
208
+ }
209
+ Some ( tls) => & * tls
210
+ } ;
194
211
195
212
match t {
196
- Ok ( term) => {
213
+ & Some ( ref term) => {
197
214
term. attr ( color) ;
198
215
stderr. write_str ( msg) ;
199
216
term. reset ( ) ;
You can’t perform that action at this time.
0 commit comments