diff options
author | Jesse Luehrs <doy@tozt.net> | 2013-03-20 00:36:08 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2013-03-20 00:36:08 -0500 |
commit | 8fc473d033a4c38f7c0024bd259ff54b9867d50d (patch) | |
tree | 945a6323eb4d457871c7e2e26fc2684cc26ddcaa /src/ios.rs | |
parent | 28eeecd93029db4b756844852e3608eba83bf455 (diff) | |
download | rust-term-8fc473d033a4c38f7c0024bd259ff54b9867d50d.tar.gz rust-term-8fc473d033a4c38f7c0024bd259ff54b9867d50d.zip |
implement getting terminal size
Diffstat (limited to 'src/ios.rs')
-rw-r--r-- | src/ios.rs | 13 |
1 files changed, 12 insertions, 1 deletions
@@ -1,4 +1,4 @@ -use core::libc::c_int; +use core::libc::{c_int,c_uint}; pub fn cooked () -> int { unsafe { c::cooked() as int } @@ -25,6 +25,15 @@ pub fn isatty() -> bool { unsafe { c_isatty(0) as bool } } +pub fn size() -> (uint, uint) { + let rows: c_uint = 0; + let cols: c_uint = 0; + unsafe { + c::size(&rows, &cols) + } + (rows as uint, cols as uint) +} + enum struct_termios {} struct PreserveTermios { @@ -50,6 +59,8 @@ extern mod c { fn get() -> *struct_termios; fn set(t: *struct_termios); + + fn size(rows: *c_uint, cols: *c_uint); } extern { |