Terminal size to 1-based (#170)
This commit is contained in:
parent
ae5a210ac9
commit
44d180cb46
@ -16,10 +16,7 @@ pub fn get_terminal_size() -> (u16, u16) {
|
|||||||
let r = unsafe { ioctl(STDOUT_FILENO, TIOCGWINSZ.into(), &mut size) };
|
let r = unsafe { ioctl(STDOUT_FILENO, TIOCGWINSZ.into(), &mut size) };
|
||||||
|
|
||||||
if r == 0 {
|
if r == 0 {
|
||||||
// because crossterm works starts counting at 0
|
(size.ws_co, size.ws_row)
|
||||||
// and unix terminal starts at cell 1
|
|
||||||
// you have subtract one to get 0-based results.
|
|
||||||
(size.ws_col - 1, size.ws_row - 1)
|
|
||||||
} else {
|
} else {
|
||||||
(0, 0)
|
(0, 0)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user