Crate term [−] [src]

Unstable

: use the crates.io term library instead

Terminal formatting library.

This crate provides the Terminal trait, which abstracts over an ANSI Terminal to provide color printing, among other things. There are two implementations, the TerminfoTerminal, which uses control characters from a terminfo database, and WinConsole, which uses the Win32 Console API.

Examples

#![feature(rustc_private)] extern crate term; use std::io::prelude::*; fn main() { let mut t = term::stdout().unwrap(); t.fg(term::color::GREEN).unwrap(); (write!(t, "hello, ")).unwrap(); t.fg(term::color::RED).unwrap(); (writeln!(t, "world!")).unwrap(); t.reset().unwrap(); }
extern crate term;

use std::io::prelude::*;

fn main() {
    let mut t = term::stdout().unwrap();

    t.fg(term::color::GREEN).unwrap();
    (write!(t, "hello, ")).unwrap();

    t.fg(term::color::RED).unwrap();
    (writeln!(t, "world!")).unwrap();

    t.reset().unwrap();
}

Reexports

pub use terminfo::TerminfoTerminal;

Modules

attr [Unstable]

Terminal attributes

color [Unstable]

Terminal color definitions

terminfo [Unstable]

Terminfo database interface.

Structs

WriterWrapper [Unstable]

A hack to work around the fact that Box<Write + Send> does not currently implement Write.

Traits

Terminal [Unstable]

A terminal with similar capabilities to an ANSI Terminal (foreground/background colors etc).

UnwrappableTerminal [Unstable]

A terminal which can be unwrapped.

Functions

stderr [Unstable]

Return a Terminal wrapping stderr, or None if a terminal couldn't be opened.

stdout [Unstable]

Return a Terminal wrapping stdout, or None if a terminal couldn't be opened.