pub fn terminal_size_using_fd(fd: RawFd) -> Option<(Width, Height)>
Expand description

Returns the size of the terminal using the given file descriptor, if available.

If the given file descriptor is not a tty, returns None

Examples found in repository?
examples/get_size.rs (line 33)
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
fn run() {
    use std::os::unix::io::AsRawFd;

    println!(
        "Size from terminal_size_using_fd(stdout):     {:?}",
        terminal_size::terminal_size_using_fd(std::io::stdout().as_raw_fd())
    );
    println!(
        "Size from terminal_size_using_fd(stderr):     {:?}",
        terminal_size::terminal_size_using_fd(std::io::stderr().as_raw_fd())
    );
    println!(
        "Size from terminal_size_using_fd(stdin):      {:?}",
        terminal_size::terminal_size_using_fd(std::io::stdin().as_raw_fd())
    );
}