Skip to content

Commit

Permalink
Merge pull request #52 from ids1024/redox
Browse files Browse the repository at this point in the history
Redox OS support
  • Loading branch information
a8m committed Jun 19, 2017
2 parents ab9743e + 43ecff5 commit fe5f8ba
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
5 changes: 5 additions & 0 deletions src/tty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
13 changes: 13 additions & 0 deletions src/tty/redox.rs
Original file line number Diff line number Diff line change
@@ -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))
}

0 comments on commit fe5f8ba

Please sign in to comment.