From 65615c3c3917aee789c88a3d03657336bb147c28 Mon Sep 17 00:00:00 2001 From: shortenda Date: Wed, 16 Mar 2016 01:43:35 -0700 Subject: [PATCH 1/3] Fix typo --- src/control.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/control.rs b/src/control.rs index 9781e69..24a68d2 100644 --- a/src/control.rs +++ b/src/control.rs @@ -11,7 +11,7 @@ pub trait TermWrite { fn csi(&mut self, b: &[u8]) -> io::Result; /// Print OSC (operating system command) followed by a byte string. fn osc(&mut self, b: &[u8]) -> io::Result; - /// Print OSC (device control string) followed by a byte string. + /// Print DSC (device control string) followed by a byte string. fn dsc(&mut self, b: &[u8]) -> io::Result; From d6161f9e24e2cbaab033cbacafb402039fe61bde Mon Sep 17 00:00:00 2001 From: Greg Chapple Date: Wed, 16 Mar 2016 12:02:29 +0000 Subject: [PATCH 2/3] Fixed keys example --- examples/keys.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/keys.rs b/examples/keys.rs index 7c30bbf..06d88a7 100644 --- a/examples/keys.rs +++ b/examples/keys.rs @@ -29,7 +29,7 @@ fn main() { Key::Down => println!("↓"), Key::Backspace => println!("×"), Key::Invalid => println!("???"), - Key::Error => println!("ERROR"), + Key::Error(_) => println!("ERROR"), _ => {}, } stdout.flush().unwrap(); From 72f87e01764344702bb3cf04c8fadc656ca74a34 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Wed, 16 Mar 2016 12:59:12 -0600 Subject: [PATCH 3/3] 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)]