diff --git a/Cargo.toml b/Cargo.toml index 1f189dfb..6c388767 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,5 +14,8 @@ time = "0.1.35" winapi = "0.2" kernel32-sys = "0.2" +[target.'cfg(target_os = "redox")'.dependencies] +termion = "1.4" + [dev-dependencies] rand = "0.3.14" diff --git a/src/tty/mod.rs b/src/tty/mod.rs index 65470201..db9dfa55 100644 --- a/src/tty/mod.rs +++ b/src/tty/mod.rs @@ -21,3 +21,8 @@ pub use self::unix::*; mod windows; #[cfg(windows)] pub use self::windows::*; + +#[cfg(target_os = "redox")] +mod redox; +#[cfg(target_os = "redox")] +pub use self::redox::*; diff --git a/src/tty/redox.rs b/src/tty/redox.rs new file mode 100644 index 00000000..2f9bd8c2 --- /dev/null +++ b/src/tty/redox.rs @@ -0,0 +1,13 @@ +extern crate termion; +use super::{Width, Height}; + +pub fn terminal_size() -> Option<(Width, Height)> { + match termion::terminal_size() { + Ok((cols, rows)) => Some((Width(cols), Height(rows))), + Err(..) => None + } +} + +pub fn move_cursor_up(n: usize) -> String { + format!("{}", termion::cursor::Up(n as u16)) +}