Function term_size::dimensions_stdin [−][src]
pub fn dimensions_stdin() -> Option<(usize, usize)>
Expand description
Query the current processes’s input (stdin
) only, in the attempt to determine
terminal width. If that stream is actually a tty, this function returns its width
and height as a number of characters.
Errors
If the stream is not a tty or return any errors this function will return None
.
Example
To get the dimensions of your terminal window, simply use the following:
if let Some((w, h)) = term_size::dimensions_stdin() {
println!("Width: {}\nHeight: {}", w, h);
} else {
println!("Unable to get term size :(")
}