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/util.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/util.rs') 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 } } -- cgit v1.2.3-54-g00ecf