diff options
author | Jesse Luehrs <doy@tozt.net> | 2013-04-08 21:56:10 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2013-04-08 21:56:10 -0500 |
commit | ad2578a7ad98de9171400aea20c38f3ca237d88e (patch) | |
tree | cc1068a80a9d7bf47e5a8b7ded0af53d3fe98c02 /src | |
parent | 50fe57cbcba4a35665e0c622852bfa33b024aea8 (diff) | |
download | rust-term-ad2578a7ad98de9171400aea20c38f3ca237d88e.tar.gz rust-term-ad2578a7ad98de9171400aea20c38f3ca237d88e.zip |
move size back to term::ios
Diffstat (limited to 'src')
-rw-r--r-- | src/ios.rs | 14 | ||||
-rw-r--r-- | src/term.rs | 2 | ||||
-rw-r--r-- | src/util.rs | 15 |
3 files changed, 14 insertions, 17 deletions
@@ -1,4 +1,4 @@ -use core::libc::{c_int,c_void}; +use core::libc::{c_int,c_uint,c_void}; use core::unstable::finally::Finally; /** @@ -53,6 +53,16 @@ pub fn preserve<T> (body: &fn () -> T) -> T { } } +/// Returns the size of the terminal, as `(columns, rows)`. +pub fn size() -> (uint, uint) { + let cols: c_uint = 0; + let rows: c_uint = 0; + unsafe { + c::size(&cols, &rows) + } + (cols as uint, rows as uint) +} + #[link_name = "termios_wrapper"] extern mod c { fn cooked () -> c_int; @@ -62,4 +72,6 @@ extern mod c { fn get() -> *c_void; fn set(t: *c_void); + + fn size(cols: *c_uint, rows: *c_uint); } diff --git a/src/term.rs b/src/term.rs index dfe6dce..0daa5ca 100644 --- a/src/term.rs +++ b/src/term.rs @@ -5,8 +5,6 @@ #[crate_type = "lib"]; -pub use util::size; - pub mod hexes; pub mod info; pub mod ios; diff --git a/src/util.rs b/src/util.rs index 09d8c11..149f425 100644 --- a/src/util.rs +++ b/src/util.rs @@ -1,4 +1,4 @@ -use core::libc::{c_int,c_uint}; +use core::libc::c_int; // XXX huge hack until there's a better built-in way to do this pub fn timed_read (timeout: int) -> Option<char> { @@ -24,16 +24,3 @@ pub fn timed_read (timeout: int) -> Option<char> { extern mod io_helper { fn timed_read (timeout: c_int) -> c_int; } - -pub fn size() -> (uint, uint) { - let cols: c_uint = 0; - let rows: c_uint = 0; - unsafe { - termios_wrapper::size(&cols, &rows) - } - (cols as uint, rows as uint) -} - -extern mod termios_wrapper { - fn size(cols: *c_uint, rows: *c_uint); -} |