pub fn terminal_size() -> Option<(Width, Height)>
Expand description
Returns the size of the terminal.
This function checks the stdout, stderr, and stdin streams (in that order).
The size of the first stream that is a TTY will be returned. If nothing
is a TTY, then None
is returned.
Examples found in repository?
examples/get_size.rs (line 4)
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}