From 3e95a135f67b52589957c14595ad3837c7f2f1e5 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Wed, 3 Apr 2013 02:43:29 -0500 Subject: actually, let's not reexport the termios stuff at the top level --- src/ios.rs | 13 +------------ src/term.rs | 3 +-- src/util.rs | 15 ++++++++++++++- test/termios.rs | 4 ++-- test/termios2.rs | 2 +- 5 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src/ios.rs b/src/ios.rs index 168d3a0..502b31e 100644 --- a/src/ios.rs +++ b/src/ios.rs @@ -1,4 +1,4 @@ -use core::libc::{c_int,c_uint,c_void}; +use core::libc::{c_int,c_void}; use util::guard; pub fn cooked () -> int { @@ -24,15 +24,6 @@ pub fn preserve (body: &fn () -> T) -> T { } } -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; @@ -42,6 +33,4 @@ 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 b8ce18e..e876dfa 100644 --- a/src/term.rs +++ b/src/term.rs @@ -5,8 +5,7 @@ #[crate_type = "lib"]; -pub use ios::{cooked,cbreak,raw,echo,size}; -pub use util::isatty; +pub use util::{isatty,size}; pub mod hexes; pub mod info; diff --git a/src/util.rs b/src/util.rs index 43a1a69..1a4e1c3 100644 --- a/src/util.rs +++ b/src/util.rs @@ -1,4 +1,4 @@ -use core::libc::c_int; +use core::libc::{c_int,c_uint}; pub fn guard (finally: ~fn (), body: &fn () -> T) -> T { let _guard = Guard { finally: finally }; @@ -40,6 +40,19 @@ 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); +} + pub fn isatty() -> bool { unsafe { c_isatty(0) as bool } } diff --git a/test/termios.rs b/test/termios.rs index 7552373..3683cee 100644 --- a/test/termios.rs +++ b/test/termios.rs @@ -2,8 +2,8 @@ extern mod term; fn main () { match os::args()[1] { - ~"echo" => term::echo(true), - ~"noecho" => term::echo(false), + ~"echo" => term::ios::echo(true), + ~"noecho" => term::ios::echo(false), _ => fail!(~"unknown argument"), }; } diff --git a/test/termios2.rs b/test/termios2.rs index 35986b2..a7b3aa9 100644 --- a/test/termios2.rs +++ b/test/termios2.rs @@ -12,7 +12,7 @@ fn loop_chars () { fn main () { do term::ios::preserve { - term::raw(); + term::ios::raw(); loop_chars(); } -- cgit v1.2.3