[−][src]Crate term
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.
Usage
This crate is on crates.io and can be
used by adding term
to the dependencies in your project's Cargo.toml
.
[dependencies]
term = "0.4.6"
and this to your crate root:
extern crate term;
Examples
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(); }
Re-exports
pub use terminfo::TerminfoTerminal; |
Modules
color | Terminal color definitions |
terminfo | Terminfo database interface. |
Structs
WinConsole | A Terminal implementation which uses the Win32 Console API. |
WinConsoleInfo | Console info which can be used by a Terminal implementation which uses the Win32 Console API. |
Enums
Attr | Terminal attributes for use with term.attr(). |
Error | An error arising from interacting with the terminal. |
Traits
Terminal | A terminal with similar capabilities to an ANSI Terminal (foreground/background colors etc). |
Functions
stderr | Return a Terminal wrapping stderr, or None if a terminal couldn't be opened. |
stdout | Return a Terminal wrapping stdout, or None if a terminal couldn't be opened. |
Type Definitions
Result | The canonical |
StderrTerminal | Alias for stderr terminals. |
StdoutTerminal | Alias for stdout terminals. |