From ad2578a7ad98de9171400aea20c38f3ca237d88e Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Mon, 8 Apr 2013 21:56:10 -0500 Subject: move size back to term::ios --- src/ios.rs | 14 +++++++++++++- src/term.rs | 2 -- src/util.rs | 15 +-------------- 3 files changed, 14 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/ios.rs b/src/ios.rs index 6f57a51..4e1c3f4 100644 --- a/src/ios.rs +++ b/src/ios.rs @@ -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 (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 { @@ -24,16 +24,3 @@ pub fn timed_read (timeout: int) -> Option { 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); -} -- cgit v1.2.3-54-g00ecf