File tree Expand file tree Collapse file tree 1 file changed +10
-10
lines changed Expand file tree Collapse file tree 1 file changed +10
-10
lines changed Original file line number Diff line number Diff line change @@ -47,22 +47,22 @@ fn c_result<F: FnOnce() -> libc::c_int>(f: F) -> io::Result<()> {
47
47
}
48
48
49
49
pub ( crate ) fn terminal_size ( out : & Term ) -> Option < ( u16 , u16 ) > {
50
- unsafe {
51
- if libc:: isatty ( out. as_raw_fd ( ) ) != 1 {
52
- return None ;
53
- }
54
-
50
+ if !is_a_terminal ( out) {
51
+ return None ;
52
+ }
53
+ let winsize = unsafe {
55
54
let mut winsize: libc:: winsize = mem:: zeroed ( ) ;
56
55
57
56
// FIXME: ".into()" used as a temporary fix for a libc bug
58
57
// https://github.com/rust-lang/libc/pull/704
59
58
#[ allow( clippy:: useless_conversion) ]
60
59
libc:: ioctl ( out. as_raw_fd ( ) , libc:: TIOCGWINSZ . into ( ) , & mut winsize) ;
61
- if winsize. ws_row > 0 && winsize. ws_col > 0 {
62
- Some ( ( winsize. ws_row as u16 , winsize. ws_col as u16 ) )
63
- } else {
64
- None
65
- }
60
+ winsize
61
+ } ;
62
+ if winsize. ws_row > 0 && winsize. ws_col > 0 {
63
+ Some ( ( winsize. ws_row as u16 , winsize. ws_col as u16 ) )
64
+ } else {
65
+ None
66
66
}
67
67
}
68
68
You can’t perform that action at this time.
0 commit comments