From c280882749e4126e8863e1e9869e16c5c46197a7 Mon Sep 17 00:00:00 2001 From: Rose Hogenson Date: Wed, 27 Dec 2023 09:52:27 -0800 Subject: Rename tiocgwinsz.rs to term.rs. I will be putting more functionality in this file. --- src/term.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/term.rs (limited to 'src/term.rs') diff --git a/src/term.rs b/src/term.rs new file mode 100644 index 0000000..f8246fd --- /dev/null +++ b/src/term.rs @@ -0,0 +1,18 @@ +use libc::{c_int, winsize}; + +pub fn size() -> Option { + let mut window: winsize = winsize { + ws_row: 0, + ws_col: 0, + ws_xpixel: 0, + ws_ypixel: 0, + }; + let result: c_int; + unsafe { + result = libc::ioctl(1, libc::TIOCGWINSZ, &mut window); + } + if result < 0 { + return None; + } + return Some(window); +} -- cgit v1.3.1