https://github.com/phundrak/output-vt100-rs
Activates ANSI escaped characters in PowerShell and CMD for your Rust code
https://github.com/phundrak/output-vt100-rs
ansi-colors cmd powershell rust windows
Last synced: 3 months ago
JSON representation
Activates ANSI escaped characters in PowerShell and CMD for your Rust code
- Host: GitHub
- URL: https://github.com/phundrak/output-vt100-rs
- Owner: Phundrak
- License: mit
- Created: 2019-02-13T23:28:38.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-02-12T23:08:49.000Z (over 3 years ago)
- Last Synced: 2025-04-13T05:13:45.354Z (3 months ago)
- Topics: ansi-colors, cmd, powershell, rust, windows
- Language: Rust
- Homepage:
- Size: 31.3 KB
- Stars: 8
- Watchers: 5
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](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<(), InitError>`# Acknowledgements
A big thank you to [nbouteme](https://github.com/nbouteme) who helped me a lot during the development of this create.