2019-02-14 13:53:02 +01:00
[](https://crates.io/crates/output_vt100)
[](https://docs.rs/output_vt100)
2019-02-14 14:17:11 +01:00
[](https://crates.io/crates/output_vt100)
2019-05-13 19:46:17 +02:00
[](https://crates.io/crates/output_vt100)
2019-02-14 13:53:02 +01:00
[](https://ci.appveyor.com/project/Phundrak/output-vt100-rs)
2022-02-12 23:21:12 +01:00
[](https://drone.phundrak.com/phundrak/output-vt100-rs)
2019-02-14 13:53:02 +01:00
2019-02-14 02:02:10 +01:00
# Output-VT100
This simple crates allows developers to enable ANSI escape characters in Windows' console, be it CMD or PowerShell. Its usage is very simple, as shown below:
```rust
extern crate output_vt100;
fn main() {
output_vt100::init();
println!("\x1b[31mThis text is red!\x1b[0m");
}
```
If you wish to ensure the `output_vt100::init()` function is only ran once, you can use the crate [ctor ](https://crates.io/crates/ctor ). Be aware though it might not be suited for every use case, as explained on the crate’ s presentation.
2019-02-14 03:09:21 +01:00
```rust
2019-02-14 02:02:10 +01:00
extern crate output_vt100;
extern crate ctor;
use ctor::*;
#[ctor]
fn init_term() {
output_vt100::init();
}
fn main() {
println!("\x1b[31mThis text is red!\x1b[0m");
}
```
2019-02-21 11:12:04 +01:00
Not that init panics on error, if you do not wish to panic, use
2022-02-13 00:08:22 +01:00
`output_vt100::try_init` which returns a `Result<(), InitError>`
2019-02-21 11:12:04 +01:00
2019-02-14 02:02:10 +01:00
# Acknowledgements
A big thank you to [nbouteme ](https://github.com/nbouteme ) who helped me a lot during the development of this create.