From 72f87e01764344702bb3cf04c8fadc656ca74a34 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Wed, 16 Mar 2016 12:59:12 -0600 Subject: [PATCH] Fix redox support --- src/raw.rs | 20 ++++++++++---------- src/size.rs | 5 +++++ 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/raw.rs b/src/raw.rs index 7e2c779..4a6bed3 100644 --- a/src/raw.rs +++ b/src/raw.rs @@ -4,14 +4,14 @@ use std::ops::{Deref, DerefMut}; /// A terminal restorer, which keeps the previous state of the terminal, and restores it, when /// dropped. #[cfg(target_os = "redox")] -pub struct RawTerminal { +pub struct RawTerminal { output: W, } #[cfg(target_os = "redox")] impl Drop for RawTerminal { fn drop(&mut self) { - use TermControl; + use control::TermWrite; self.csi(b"R"); } } @@ -21,27 +21,27 @@ use termios::Termios; /// A terminal restorer, which keeps the previous state of the terminal, and restores it, when /// dropped. #[cfg(not(target_os = "redox"))] -pub struct RawTerminal { +pub struct RawTerminal { prev_ios: Termios, output: W, } #[cfg(not(target_os = "redox"))] -impl Drop for RawTerminal { +impl Drop for RawTerminal { fn drop(&mut self) { use termios::set_terminal_attr; set_terminal_attr(&mut self.prev_ios as *mut _); } } -impl Deref for RawTerminal { +impl Deref for RawTerminal { type Target = W; fn deref(&self) -> &W { &self.output } } -impl DerefMut for RawTerminal { +impl DerefMut for RawTerminal { fn deref_mut(&mut self) -> &mut W { &mut self.output } @@ -58,7 +58,7 @@ impl Write for RawTerminal { } /// Types which can be converted into "raw mode". -pub trait IntoRawMode: Sized { +pub trait IntoRawMode: Write + Sized { /// Switch to raw mode. /// /// Raw mode means that stdin won't be printed (it will instead have to be written manually by the @@ -92,10 +92,10 @@ impl IntoRawMode for W { } } #[cfg(target_os = "redox")] - fn into_raw_mode(self) -> IoResult> { - use TermControl; + fn into_raw_mode(mut self) -> IoResult> { + use control::TermWrite; - self.csi("r").map(|_| RawTerminal { + self.csi(b"r").map(|_| RawTerminal { output: self, }) } diff --git a/src/size.rs b/src/size.rs index f7e9af9..09aabc8 100644 --- a/src/size.rs +++ b/src/size.rs @@ -13,11 +13,13 @@ struct TermSize { } // Since attributes on non-item statements is not stable yet, we use a function. +#[cfg(not(target_os = "redox"))] #[cfg(target_pointer_width = "64")] fn tiocgwinsz() -> u64 { use termios::TIOCGWINSZ; TIOCGWINSZ as u64 } +#[cfg(not(target_os = "redox"))] #[cfg(target_pointer_width = "32")] fn tiocgwinsz() -> u32 { use termios::TIOCGWINSZ; @@ -46,6 +48,7 @@ pub fn terminal_size() -> io::Result<(usize, usize)> { /// Get the size of the terminal. #[cfg(target_os = "redox")] pub fn terminal_size() -> io::Result<(usize, usize)> { + /* fn get_int(s: &'static str) -> io::Result { use std::env; @@ -58,6 +61,8 @@ pub fn terminal_size() -> io::Result<(usize, usize)> { } Ok((try!(get_int("COLUMNS")), try!(get_int("LINES")))) + */ + Ok((128,48)) } #[cfg(test)]