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,13 +96,6 @@ pub trait TermWrite {
|
||||||
/// Set foreground color.
|
/// Set foreground color.
|
||||||
fn color(&mut self, color: Color) -> io::Result<usize> {
|
fn color(&mut self, color: Color) -> io::Result<usize> {
|
||||||
let ansi = color.to_ansi_val();
|
let ansi = color.to_ansi_val();
|
||||||
if ansi <= 7 {
|
|
||||||
self.csi(&[
|
|
||||||
b'3',
|
|
||||||
b'0' + ansi,
|
|
||||||
b'm',
|
|
||||||
])
|
|
||||||
} else {
|
|
||||||
self.csi(&[
|
self.csi(&[
|
||||||
b'3',
|
b'3',
|
||||||
b'8',
|
b'8',
|
||||||
|
@ -115,18 +108,9 @@ pub trait TermWrite {
|
||||||
b'm',
|
b'm',
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
}
|
|
||||||
/// Set background color.
|
/// Set background color.
|
||||||
fn bg_color(&mut self, color: Color) -> io::Result<usize> {
|
fn bg_color(&mut self, color: Color) -> io::Result<usize> {
|
||||||
let ansi = color.to_ansi_val();
|
let ansi = color.to_ansi_val();
|
||||||
|
|
||||||
if ansi <= 7 {
|
|
||||||
self.csi(&[
|
|
||||||
b'4',
|
|
||||||
b'0' + ansi,
|
|
||||||
b'm',
|
|
||||||
])
|
|
||||||
} else {
|
|
||||||
self.csi(&[
|
self.csi(&[
|
||||||
b'4',
|
b'4',
|
||||||
b'8',
|
b'8',
|
||||||
|
@ -139,7 +123,6 @@ pub trait TermWrite {
|
||||||
b'm',
|
b'm',
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
}
|
|
||||||
/// Set rendition mode (SGR).
|
/// Set rendition mode (SGR).
|
||||||
fn style(&mut self, mode: Style) -> io::Result<usize> {
|
fn style(&mut self, mode: Style) -> io::Result<usize> {
|
||||||
self.rendition(mode as u8)
|
self.rendition(mode as u8)
|
||||||
|
|
|
@ -3,10 +3,6 @@
|
||||||
//! This crate is not stable, yet. However, if you do want stability, you should specify the
|
//! 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
|
//! revision (commit hash) in your `Cargo.toml`, this way builds are complete reproducible, and won't
|
||||||
//! break.
|
//! break.
|
||||||
|
|
||||||
#![cfg_attr(feature = "nightly",
|
|
||||||
feature(io))]
|
|
||||||
|
|
||||||
#![warn(missing_docs)]
|
#![warn(missing_docs)]
|
||||||
|
|
||||||
|
|
||||||
|
|
15
src/size.rs
15
src/size.rs
|
@ -48,21 +48,12 @@ pub fn terminal_size() -> io::Result<(usize, usize)> {
|
||||||
/// Get the size of the terminal.
|
/// Get the size of the terminal.
|
||||||
#[cfg(target_os = "redox")]
|
#[cfg(target_os = "redox")]
|
||||||
pub fn terminal_size() -> io::Result<(usize, usize)> {
|
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 {
|
let width = env::var("COLUMNS").unwrap_or(String::new()).parse::<usize>().unwrap_or(0);
|
||||||
env::VarError::NotPresent => io::Error::new(io::ErrorKind::NotFound, e),
|
let height = env::var("LINES").unwrap_or(String::new()).parse::<usize>().unwrap_or(0);
|
||||||
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))
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok((try!(get_int("COLUMNS")), try!(get_int("LINES"))))
|
Ok((width, height))
|
||||||
*/
|
|
||||||
Ok((128,48))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
Loading…
Reference in New Issue