1515
1616use std:: io:: { Decorator , Writer } ;
1717
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 } ;
2323
2424// FIXME (#2807): Windows support.
2525
@@ -74,7 +74,6 @@ pub mod attr {
7474 }
7575}
7676
77- #[ cfg( not( target_os = "win32" ) ) ]
7877fn cap_for_attr ( attr : attr:: Attr ) -> & ' static str {
7978 match attr {
8079 attr:: Bold => "bold" ,
@@ -93,29 +92,24 @@ fn cap_for_attr(attr: attr::Attr) -> &'static str {
9392 }
9493}
9594
96- #[ cfg( not( target_os = "win32" ) ) ]
9795pub struct Terminal < T > {
9896 priv num_colors : u16 ,
9997 priv out: T ,
10098 priv ti: ~TermInfo
10199}
102100
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" ) ) ]
110101impl < T : Writer > Terminal < T > {
111102 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+ } ;
116107
117- let entry = open ( term. unwrap ( ) ) ;
108+ let entry = open ( term) ;
118109 if entry. is_err ( ) {
110+ if "cygwin" == term { // msys terminal
111+ return Ok ( Terminal { out : out, ti : msys_terminfo ( ) , num_colors : 8 } ) ;
112+ }
119113 return Err ( entry. unwrap_err ( ) ) ;
120114 }
121115
@@ -241,32 +235,6 @@ impl<T: Writer> Terminal<T> {
241235 }
242236}
243237
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-
270238impl < T : Writer > Decorator < T > for Terminal < T > {
271239 fn inner ( self ) -> T {
272240 self . out
0 commit comments