aboutsummaryrefslogtreecommitdiff
path: root/vendor/terminal_size/examples
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2024-01-08 00:21:28 +0300
committerValentin Popov <valentin@popov.link>2024-01-08 00:21:28 +0300
commit1b6a04ca5504955c571d1c97504fb45ea0befee4 (patch)
tree7579f518b23313e8a9748a88ab6173d5e030b227 /vendor/terminal_size/examples
parent5ecd8cf2cba827454317368b68571df0d13d7842 (diff)
downloadfparkan-1b6a04ca5504955c571d1c97504fb45ea0befee4.tar.xz
fparkan-1b6a04ca5504955c571d1c97504fb45ea0befee4.zip
Initial vendor packages
Signed-off-by: Valentin Popov <valentin@popov.link>
Diffstat (limited to 'vendor/terminal_size/examples')
-rw-r--r--vendor/terminal_size/examples/get_size.rs49
1 files changed, 49 insertions, 0 deletions
diff --git a/vendor/terminal_size/examples/get_size.rs b/vendor/terminal_size/examples/get_size.rs
new file mode 100644
index 0000000..155784d
--- /dev/null
+++ b/vendor/terminal_size/examples/get_size.rs
@@ -0,0 +1,49 @@
+#[cfg(windows)]
+fn run() {
+ use std::os::windows::io::RawHandle;
+ use winapi::um::processenv::GetStdHandle;
+ use winapi::um::winbase::{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() {
+ println!(
+ "Size from terminal_size_using_fd(stdout): {:?}",
+ terminal_size::terminal_size_using_fd(libc::STDOUT_FILENO)
+ );
+ println!(
+ "Size from terminal_size_using_fd(stderr): {:?}",
+ terminal_size::terminal_size_using_fd(libc::STDERR_FILENO)
+ );
+ println!(
+ "Size from terminal_size_using_fd(stdin): {:?}",
+ terminal_size::terminal_size_using_fd(libc::STDIN_FILENO)
+ );
+}
+
+fn main() {
+ println!(
+ "Size from terminal_size(): {:?}",
+ terminal_size::terminal_size()
+ );
+
+ run();
+}