15
15
16
16
use std:: io:: { Decorator , Writer } ;
17
17
18
- # [ cfg ( not ( target_os = "win32" ) ) ] use std:: os;
19
- # [ cfg ( not ( target_os = "win32" ) ) ] use terminfo:: * ;
20
- # [ cfg ( not ( target_os = "win32" ) ) ] use terminfo:: searcher:: open;
21
- # [ cfg ( not ( target_os = "win32" ) ) ] use terminfo:: parser:: compiled:: parse;
22
- # [ cfg ( not ( target_os = "win32" ) ) ] use terminfo:: parm:: { expand, Number , Variables } ;
18
+ use std:: os;
19
+ use terminfo:: * ;
20
+ use terminfo:: searcher:: open;
21
+ use terminfo:: parser:: compiled:: { parse, msys_terminfo } ;
22
+ use terminfo:: parm:: { expand, Number , Variables } ;
23
23
24
24
// FIXME (#2807): Windows support.
25
25
@@ -74,7 +74,6 @@ pub mod attr {
74
74
}
75
75
}
76
76
77
- #[ cfg( not( target_os = "win32" ) ) ]
78
77
fn cap_for_attr ( attr : attr:: Attr ) -> & ' static str {
79
78
match attr {
80
79
attr:: Bold => "bold" ,
@@ -93,29 +92,24 @@ fn cap_for_attr(attr: attr::Attr) -> &'static str {
93
92
}
94
93
}
95
94
96
- #[ cfg( not( target_os = "win32" ) ) ]
97
95
pub struct Terminal < T > {
98
96
priv num_colors : u16 ,
99
97
priv out: T ,
100
98
priv ti: ~TermInfo
101
99
}
102
100
103
- #[ cfg( target_os = "win32" ) ]
104
- pub struct Terminal < T > {
105
- priv num_colors : u16 ,
106
- priv out: T ,
107
- }
108
-
109
- #[ cfg( not( target_os = "win32" ) ) ]
110
101
impl < T : Writer > Terminal < T > {
111
102
pub fn new ( out : T ) -> Result < Terminal < T > , ~str > {
112
- let term = os:: getenv ( "TERM" ) ;
113
- if term . is_none ( ) {
114
- return Err ( ~"TERM environment variable undefined") ;
115
- }
103
+ let term = match os:: getenv ( "TERM" ) {
104
+ Some ( t ) => t ,
105
+ None => return Err ( ~"TERM environment variable undefined")
106
+ } ;
116
107
117
- let entry = open ( term. unwrap ( ) ) ;
108
+ let entry = open ( term) ;
118
109
if entry. is_err ( ) {
110
+ if "cygwin" == term { // msys terminal
111
+ return Ok ( Terminal { out : out, ti : msys_terminfo ( ) , num_colors : 8 } ) ;
112
+ }
119
113
return Err ( entry. unwrap_err ( ) ) ;
120
114
}
121
115
@@ -241,32 +235,6 @@ impl<T: Writer> Terminal<T> {
241
235
}
242
236
}
243
237
244
- #[ cfg( target_os = "win32" ) ]
245
- impl < T : Writer > Terminal < T > {
246
- pub fn new ( out : T ) -> Result < Terminal < T > , ~str > {
247
- return Ok ( Terminal { out : out, num_colors : 0 } ) ;
248
- }
249
-
250
- pub fn fg ( & mut self , _color : color:: Color ) -> bool {
251
- false
252
- }
253
-
254
- pub fn bg ( & mut self , _color : color:: Color ) -> bool {
255
- false
256
- }
257
-
258
- pub fn attr ( & mut self , _attr : attr:: Attr ) -> bool {
259
- false
260
- }
261
-
262
- pub fn supports_attr ( & self , _attr : attr:: Attr ) -> bool {
263
- false
264
- }
265
-
266
- pub fn reset ( & self ) {
267
- }
268
- }
269
-
270
238
impl < T : Writer > Decorator < T > for Terminal < T > {
271
239
fn inner ( self ) -> T {
272
240
self . out
0 commit comments