@@ -32,13 +32,15 @@ use iter::repeat;
32
32
use libc:: types:: os:: arch:: extra:: LPCVOID ;
33
33
use libc:: { c_int, HANDLE , LPDWORD , DWORD , LPVOID } ;
34
34
use libc:: { get_osfhandle, CloseHandle } ;
35
+ use mem;
35
36
use ptr;
36
37
use str:: from_utf8;
37
38
use super :: c:: { ENABLE_ECHO_INPUT , ENABLE_EXTENDED_FLAGS } ;
38
39
use super :: c:: { ENABLE_INSERT_MODE , ENABLE_LINE_INPUT } ;
39
40
use super :: c:: { ENABLE_PROCESSED_INPUT , ENABLE_QUICK_EDIT_MODE } ;
40
- use super :: c:: { ERROR_ILLEGAL_CHARACTER } ;
41
+ use super :: c:: { ERROR_ILLEGAL_CHARACTER , CONSOLE_SCREEN_BUFFER_INFO } ;
41
42
use super :: c:: { ReadConsoleW , WriteConsoleW , GetConsoleMode , SetConsoleMode } ;
43
+ use super :: c:: { GetConsoleScreenBufferInfo } ;
42
44
43
45
fn invalid_encoding ( ) -> IoError {
44
46
IoError {
@@ -146,12 +148,12 @@ impl TTY {
146
148
}
147
149
148
150
pub fn get_winsize ( & mut self ) -> IoResult < ( int , int ) > {
149
- // FIXME
150
- // Get console buffer via CreateFile with CONOUT$
151
- // Make a CONSOLE_SCREEN_BUFFER_INFO
152
- // Call GetConsoleScreenBufferInfo
153
- // Maybe call GetLargestConsoleWindowSize instead?
154
- Err ( super :: unimpl ( ) )
151
+ let mut info : CONSOLE_SCREEN_BUFFER_INFO = unsafe { mem :: zeroed ( ) } ;
152
+ match unsafe { GetConsoleScreenBufferInfo ( self . handle , & mut info as * mut _ ) } {
153
+ 0 => Err ( super :: last_error ( ) ) ,
154
+ _ => Ok ( ( ( info . srWindow . Right + 1 - info . srWindow . Left ) as int ,
155
+ ( info . srWindow . Bottom + 1 - info . srWindow . Top ) as int ) ) ,
156
+ }
155
157
}
156
158
157
159
// Let us magically declare this as a TTY
0 commit comments