From 50fe57cbcba4a35665e0c622852bfa33b024aea8 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Mon, 8 Apr 2013 21:51:14 -0500 Subject: isatty is already exposed, no need to do it again --- src/term.rs | 2 +- src/util.rs | 9 --------- test/termios3.rs | 14 ++++++++------ 3 files changed, 9 insertions(+), 16 deletions(-) diff --git a/src/term.rs b/src/term.rs index e876dfa..dfe6dce 100644 --- a/src/term.rs +++ b/src/term.rs @@ -5,7 +5,7 @@ #[crate_type = "lib"]; -pub use util::{isatty,size}; +pub use util::size; pub mod hexes; pub mod info; diff --git a/src/util.rs b/src/util.rs index 2b3580e..09d8c11 100644 --- a/src/util.rs +++ b/src/util.rs @@ -37,12 +37,3 @@ pub fn size() -> (uint, uint) { extern mod termios_wrapper { fn size(cols: *c_uint, rows: *c_uint); } - -pub fn isatty() -> bool { - unsafe { c_isatty(0) as bool } -} - -extern { - #[link_name = "isatty"] - fn c_isatty(fd: c_int) -> c_int; -} diff --git a/test/termios3.rs b/test/termios3.rs index 9e24979..c387260 100644 --- a/test/termios3.rs +++ b/test/termios3.rs @@ -1,11 +1,13 @@ extern mod term; fn main () { - if term::isatty() { - let (cols, rows) = term::size(); - println(fmt!("tty: %d %d", cols as int, rows as int)); - } - else { - println("not tty"); + match io::stdout().get_type() { + io::Screen => { + let (cols, rows) = term::size(); + println(fmt!("tty: %d %d", cols as int, rows as int)); + } + io::File => { + println("not tty"); + } } } -- cgit v1.2.3