pub fn terminal_size_of<Fd: AsFd>(fd: Fd) -> 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 9)
1fn main() {
2 println!(
3 "Size from terminal_size(): {:?}",
4 terminal_size::terminal_size()
5 );
6
7 println!(
8 "Size from terminal_size_of(stdout): {:?}",
9 terminal_size::terminal_size_of(std::io::stdout())
10 );
11 println!(
12 "Size from terminal_size_of(stderr): {:?}",
13 terminal_size::terminal_size_of(std::io::stderr())
14 );
15 println!(
16 "Size from terminal_size_of(stdin): {:?}",
17 terminal_size::terminal_size_of(std::io::stdin())
18 );
19}