Terminal size to 1-based (#170)

This commit is contained in:
Odin Dutton 2019-07-06 13:33:37 +02:00 committed by Timon
parent ae5a210ac9
commit 44d180cb46

View File

@ -16,10 +16,7 @@ pub fn get_terminal_size() -> (u16, u16) {
let r = unsafe { ioctl(STDOUT_FILENO, TIOCGWINSZ.into(), &mut size) };
if r == 0 {
// because crossterm works starts counting at 0
// and unix terminal starts at cell 1
// you have subtract one to get 0-based results.
(size.ws_col - 1, size.ws_row - 1)
(size.ws_co, size.ws_row)
} else {
(0, 0)
}