diff --git a/src/control.rs b/src/control.rs index d509121..24a68d2 100644 --- a/src/control.rs +++ b/src/control.rs @@ -96,49 +96,32 @@ pub trait TermWrite { /// Set foreground color. fn color(&mut self, color: Color) -> io::Result { let ansi = color.to_ansi_val(); - if ansi <= 7 { - self.csi(&[ - b'3', - b'0' + ansi, - b'm', - ]) - } else { - self.csi(&[ - b'3', - b'8', - b';', - b'5', - b';', - b'0' + ansi / 100, - b'0' + ansi / 10 % 10, - b'0' + ansi % 10, - b'm', - ]) - } + self.csi(&[ + b'3', + b'8', + b';', + b'5', + b';', + b'0' + ansi / 100, + b'0' + ansi / 10 % 10, + b'0' + ansi % 10, + b'm', + ]) } /// Set background color. fn bg_color(&mut self, color: Color) -> io::Result { let ansi = color.to_ansi_val(); - - if ansi <= 7 { - self.csi(&[ - b'4', - b'0' + ansi, - b'm', - ]) - } else { - self.csi(&[ - b'4', - b'8', - b';', - b'5', - b';', - b'0' + ansi / 100, - b'0' + ansi / 10 % 10, - b'0' + ansi % 10, - b'm', - ]) - } + self.csi(&[ + b'4', + b'8', + b';', + b'5', + b';', + b'0' + ansi / 100, + b'0' + ansi / 10 % 10, + b'0' + ansi % 10, + b'm', + ]) } /// Set rendition mode (SGR). fn style(&mut self, mode: Style) -> io::Result { diff --git a/src/lib.rs b/src/lib.rs index 2a2b34c..5e4aaea 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,10 +3,6 @@ //! This crate is not stable, yet. However, if you do want stability, you should specify the //! revision (commit hash) in your `Cargo.toml`, this way builds are complete reproducible, and won't //! break. - -#![cfg_attr(feature = "nightly", - feature(io))] - #![warn(missing_docs)] diff --git a/src/size.rs b/src/size.rs index 09aabc8..c8a57c6 100644 --- a/src/size.rs +++ b/src/size.rs @@ -48,21 +48,12 @@ 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; + use std::env; - env::var(s).map_err(|e| match e { - env::VarError::NotPresent => io::Error::new(io::ErrorKind::NotFound, e), - env::VarError::NotUnicode(u) => io::Error::new(io::ErrorKind::InvalidData, u), - }).and_then(|x| { - x.parse().map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e)) - }) - } + let width = env::var("COLUMNS").unwrap_or(String::new()).parse::().unwrap_or(0); + let height = env::var("LINES").unwrap_or(String::new()).parse::().unwrap_or(0); - Ok((try!(get_int("COLUMNS")), try!(get_int("LINES")))) - */ - Ok((128,48)) + Ok((width, height)) } #[cfg(test)]