You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 1.7 KiB

1 year ago
1 year ago
1 year ago
12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. [![crates.io](https://img.shields.io/crates/v/output_vt100.svg?style=flat)](https://crates.io/crates/output_vt100)
  2. [![Released API docs](https://docs.rs/output_vt100/badge.svg)](https://docs.rs/output_vt100)
  3. [![Downloads](https://img.shields.io/crates/d/output_vt100.svg?style=flat)](https://crates.io/crates/output_vt100)
  4. [![MIT Licensed](https://img.shields.io/crates/l/output_vt100.svg?style=flat)](https://crates.io/crates/output_vt100)
  5. [![AppVeyor CI](https://img.shields.io/appveyor/ci/Phundrak/output-vt100-rs.svg?style=flat)](https://ci.appveyor.com/project/Phundrak/output-vt100-rs)
  6. [![pipeline status](http://labs.phundrak.fr/phundrak/output-vt100-rs/badges/master/pipeline.svg)](http://labs.phundrak.fr/phundrak/output-vt100-rs/commits/master)
  7. # Output-VT100
  8. 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:
  9. ```rust
  10. extern crate output_vt100;
  11. fn main() {
  12. output_vt100::init();
  13. println!("\x1b[31mThis text is red!\x1b[0m");
  14. }
  15. ```
  16. 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.
  17. ```rust
  18. extern crate output_vt100;
  19. extern crate ctor;
  20. use ctor::*;
  21. #[ctor]
  22. fn init_term() {
  23. output_vt100::init();
  24. }
  25. fn main() {
  26. println!("\x1b[31mThis text is red!\x1b[0m");
  27. }
  28. ```
  29. Not that init panics on error, if you do not wish to panic, use
  30. `output_vt100::try_init` which returns a `Result<(), ()>`
  31. # Acknowledgements
  32. A big thank you to [nbouteme](https://github.com/nbouteme) who helped me a lot during the development of this create.