Utilities to control a ANSI-escapes compliant terminal device from a client application.
```rust extern crate terminal_escapes;
use terminal_escapes::{ Sequence::, Attribute::, Color };
fn main() { println!( "{}Hello {}World!{}", SetAttributes(&[Foreground(Color::Red)]), SetAttributes(&[Foreground(Color::Blue), Bright]), SetAttributes(&[Default]), ); } ```
For now the supported escape sequences are rather limited, and the library is not extensively tested. I'll come back soon to this project to have a more exhaustive implementation of the protocols. In the meantime, you are welcome to participate.
If you only plan to use this crate to just format the output with colors,
then you can just use the Sequence
enum to put escape sequences in the output
stream.
rust
print!("{}", Sequence::SetAttributes(Background(Color::Green)));
Escapes sequences can also be used to interact with the terminal just like
a regular client-server protocol.
In that case the setup, with the Device
struct, is a but more complicated
since it will need to access the program input stream.
Here are some elements I want to add in this crate in the future:
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.