Function terminal_size::terminal_size_using_handle
source · pub fn terminal_size_using_handle(handle: RawHandle) -> Option<(Width, Height)>
Expand description
Returns the size of the terminal using the given handle, if available.
If the given handle is not a tty, returns None
Examples found in repository?
examples/get_size.rs (line 11)
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
fn run() {
use std::os::windows::io::RawHandle;
use windows_sys::Win32::System::Console::{
GetStdHandle, STD_ERROR_HANDLE, STD_INPUT_HANDLE, STD_OUTPUT_HANDLE,
};
let stdout = unsafe { GetStdHandle(STD_OUTPUT_HANDLE) } as RawHandle;
println!(
"Size from terminal_size_using_handle(stdout): {:?}",
terminal_size::terminal_size_using_handle(stdout)
);
let stderr = unsafe { GetStdHandle(STD_ERROR_HANDLE) } as RawHandle;
println!(
"Size from terminal_size_using_handle(stderr): {:?}",
terminal_size::terminal_size_using_handle(stderr)
);
let stdin = unsafe { GetStdHandle(STD_INPUT_HANDLE) } as RawHandle;
println!(
"Size from terminal_size_using_handle(stdin): {:?}",
terminal_size::terminal_size_using_handle(stdin)
);
}