blob: 72e45a13e3bbe3efbdf6e9cdb68a1474656844b9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
[](https://crates.io/crates/output_vt100)
[](https://docs.rs/output_vt100)
[](https://crates.io/crates/output_vt100)
[](https://crates.io/crates/output_vt100)
[](https://ci.appveyor.com/project/Phundrak/output-vt100-rs)
[](https://drone.phundrak.com/phundrak/output-vt100-rs)
# 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.
```rust
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");
}
```
Not that init panics on error, if you do not wish to panic, use
`output_vt100::try_init` which returns a `Result<(), ()>`
# Acknowledgements
A big thank you to [nbouteme](https://github.com/nbouteme) who helped me a lot during the development of this create.
|