Use env for terminal size in redox
Undo color changes to test redox 256 color support Get terminal size for Redox's kernel terminal Use env for terminal size in redox
This commit is contained in:
parent
cd59514615
commit
f5936c0035
|
@ -96,49 +96,32 @@ pub trait TermWrite {
|
|||
/// Set foreground color.
|
||||
fn color(&mut self, color: Color) -> io::Result<usize> {
|
||||
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<usize> {
|
||||
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<usize> {
|
||||
|
|
|
@ -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)]
|
||||
|
||||
|
||||
|
|
17
src/size.rs
17
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<usize> {
|
||||
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::<usize>().unwrap_or(0);
|
||||
let height = env::var("LINES").unwrap_or(String::new()).parse::<usize>().unwrap_or(0);
|
||||
|
||||
Ok((try!(get_int("COLUMNS")), try!(get_int("LINES"))))
|
||||
*/
|
||||
Ok((128,48))
|
||||
Ok((width, height))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
Loading…
Reference in New Issue