[src]

Struct term::Terminal

pub struct Terminal<T> {
    // some fields omitted
}

A Terminal that knows how many colors it supports, with a reference to its parsed TermInfo database record.

Methods

impl<T: Writer> Terminal<T>

fn new(out: T) -> Result<Terminal<T>, ~str>

Returns a wrapped output stream (Terminal<T>) as a Result.

Returns Err() if the TERM environment variable is undefined. TERM should be set to something like xterm-color or screen-256color.

Returns Err() on failure to open the terminfo database correctly. Also, in the event that the individual terminfo database entry can not be parsed.

fn fg(&mut self, color: Color) -> IoResult<bool>

Sets the foreground color to the given color.

If the color is a bright color, but the terminal only supports 8 colors, the corresponding normal color will be used instead.

Returns Ok(true) if the color was set, Ok(false) otherwise, and Err(e) if there was an I/O error.

fn bg(&mut self, color: Color) -> IoResult<bool>

Sets the background color to the given color.

If the color is a bright color, but the terminal only supports 8 colors, the corresponding normal color will be used instead.

Returns Ok(true) if the color was set, Ok(false) otherwise, and Err(e) if there was an I/O error.

fn attr(&mut self, attr: Attr) -> IoResult<bool>

Sets the given terminal attribute, if supported. Returns Ok(true) if the attribute was supported, Ok(false) otherwise, and Err(e) if there was an I/O error.

fn supports_attr(&self, attr: Attr) -> bool

Returns whether the given terminal attribute is supported.

fn reset(&mut self) -> IoResult<()>

Resets all terminal attributes and color to the default. Returns Ok().

fn unwrap(self) -> T

Returns the contained stream

fn get_ref<'a>(&'a self) -> &'a T

Gets an immutable reference to the stream inside

fn get_mut<'a>(&'a mut self) -> &'a mut T

Gets a mutable reference to the stream inside

Trait Implementations

impl<T: Writer> Writer for Terminal<T>

fn write(&mut self, buf: &[u8]) -> IoResult<()>

fn flush(&mut self) -> IoResult<()>