output_vt100

Crates.iooutput_vt100
lib.rsoutput_vt100
version0.1.3
sourcesrc
created_at2019-02-14 01:05:34.50803
updated_at2022-02-12 22:53:53.866316
descriptionUtility to activate escape codes in Windows' CMD and PowerShell
homepage
repositoryhttps://github.com/Phundrak/output-vt100-rs
max_upload_size
id114649
size10,177
Nabil Boutemeur (nbouteme)

documentation

README

crates.io Released API docs Downloads MIT Licensed AppVeyor CI Build Status

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:

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. Be aware though it might not be suited for every use case, as explained on the crate’s presentation.

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 who helped me a lot during the development of this create.

Commit count: 27

cargo fmt