aboutsummaryrefslogtreecommitdiffstats
path: root/src/tiocgwinsz.rs
blob: f8246fd2ac6580ddee5fd5275de60a629060e685 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use libc::{c_int, winsize};

pub fn size() -> Option<winsize> {
    let mut window: winsize = winsize {
        ws_row: 0,
        ws_col: 0,
        ws_xpixel: 0,
        ws_ypixel: 0,
    };
    let result: c_int;
    unsafe {
        result = libc::ioctl(1, libc::TIOCGWINSZ, &mut window);
    }
    if result < 0 {
        return None;
    }
    return Some(window);
}