Skip to content

Commit

Permalink
Windows: Correct result of Terminal::size
Browse files Browse the repository at this point in the history
  • Loading branch information
murarth committed Apr 19, 2020
1 parent 23dbfcf commit 57c8301
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/windows/terminal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1019,7 +1019,13 @@ unsafe fn console_mode(handle: HANDLE) -> io::Result<DWORD> {
unsafe fn console_size(handle: HANDLE) -> io::Result<Size> {
let info = console_info(handle)?;

Ok(coord_to_size(info.dwSize))
let lines = (info.srWindow.Right - info.srWindow.Left + 1) as usize;
let columns = (info.srWindow.Bottom - info.srWindow.Top + 1) as usize;

Ok(Size {
lines,
columns,
})
}

unsafe fn set_console_mode(handle: HANDLE, mode: DWORD) -> io::Result<()> {
Expand Down Expand Up @@ -1102,13 +1108,6 @@ fn coord_to_cursor(pos: COORD) -> Cursor {
}
}

fn coord_to_size(size: COORD) -> Size {
Size{
lines: size.Y as usize,
columns: size.X as usize,
}
}

fn cursor_to_coord(pos: Cursor) -> COORD {
COORD{
Y: to_short(pos.line),
Expand Down

0 comments on commit 57c8301

Please sign in to comment.