This commit is contained in:
Timon 2022-07-02 21:31:26 +02:00
parent 59844ef8c7
commit caea65628c

View File

@ -39,11 +39,13 @@ pub(crate) fn size() -> Result<(u16, u16)> {
STDOUT_FILENO
};
if wrap_with_result(unsafe { ioctl(fd, TIOCGWINSZ.into(), &mut size) }).is_ok() {
if size.ws_col != 0 && size.ws_row != 0 {
return Ok((size.ws_col, size.ws_row));
}
if wrap_with_result(unsafe { ioctl(fd, TIOCGWINSZ.into(), &mut size) }).is_ok()
&& size.ws_col != 0
&& size.ws_row != 0
{
return Ok((size.ws_col, size.ws_row));
}
tput_size().ok_or_else(|| std::io::Error::last_os_error().into())
}