From 218caa410aa38c29984be31a5229b9fa717560ee Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:19:13 +0200 Subject: Merging upstream version 1.68.2+dfsg1. Signed-off-by: Daniel Baumann --- vendor/terminal_size/examples/get_size.rs | 52 +++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 vendor/terminal_size/examples/get_size.rs (limited to 'vendor/terminal_size/examples') diff --git a/vendor/terminal_size/examples/get_size.rs b/vendor/terminal_size/examples/get_size.rs new file mode 100644 index 000000000..9039b429b --- /dev/null +++ b/vendor/terminal_size/examples/get_size.rs @@ -0,0 +1,52 @@ +#[cfg(windows)] +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) + ); +} + +#[cfg(not(windows))] +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()) + ); +} + +fn main() { + println!( + "Size from terminal_size(): {:?}", + terminal_size::terminal_size() + ); + + run(); +} -- cgit v1.2.3