diff options
| author | Rose Hogenson <rosehogenson@posteo.net> | 2023-12-27 09:52:27 -0800 |
|---|---|---|
| committer | Rose Hogenson <rosehogenson@posteo.net> | 2023-12-27 09:52:27 -0800 |
| commit | c280882749e4126e8863e1e9869e16c5c46197a7 (patch) | |
| tree | 365a9d7c9bd4da2469e797a383f84be0a1d17d92 /src/term.rs | |
| parent | d754bf29a7f6c60bb3617518bc72c0f17a36fe50 (diff) | |
| download | editor-c280882749e4126e8863e1e9869e16c5c46197a7.tar.zst | |
Rename tiocgwinsz.rs to term.rs.
I will be putting more functionality in this file.
Diffstat (limited to 'src/term.rs')
| -rw-r--r-- | src/term.rs | 18 |
1 files changed, 18 insertions, 0 deletions
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<winsize> { + 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); +} |
