Added tests and documentation
This commit is contained in:
		
							parent
							
								
									2ceffe44e1
								
							
						
					
					
						commit
						653182b407
					
				@ -1,6 +1,6 @@
 | 
			
		||||
[package]
 | 
			
		||||
name = "output_vt100"
 | 
			
		||||
version = "0.1.0"
 | 
			
		||||
version = "0.1.1"
 | 
			
		||||
authors = ["Phuntsok Drak-pa <phundrak@phundrak.fr>"]
 | 
			
		||||
edition = "2018"
 | 
			
		||||
description = "Utility to activate escape codes in Windows' CMD and PowerShell"
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										32
									
								
								src/lib.rs
									
									
									
									
									
								
							
							
						
						
									
										32
									
								
								src/lib.rs
									
									
									
									
									
								
							@ -1,3 +1,27 @@
 | 
			
		||||
//! # Output-VT100
 | 
			
		||||
//!
 | 
			
		||||
//! When you write terminal-based crates, sometimes you might want to use the
 | 
			
		||||
//! standard ANSI escaped characters, to display some colors, to display text
 | 
			
		||||
//! as bold, italic or whatever. However, you’ve just discovered all your
 | 
			
		||||
//! pretty displays that worked like a charm on Linux and Mac look terrible
 | 
			
		||||
//! on Windows, because the escaped characters do not work. Rather, they are
 | 
			
		||||
//! not activated by default. Then you discover you have to do system calls to
 | 
			
		||||
//! Windows directly to activate them in order to get your beautiful text back.
 | 
			
		||||
//! What a pain!
 | 
			
		||||
//! And this is where this crate comes in action! Simply add it as a dependency
 | 
			
		||||
//! for your own crate, and use it like this:
 | 
			
		||||
//! ```rust
 | 
			
		||||
//! extern crate output_vt100;
 | 
			
		||||
//!
 | 
			
		||||
//! fn main() {
 | 
			
		||||
//!     output_vt100::init();
 | 
			
		||||
//!     println!("\x1b[31mThis text is red!\x1b[0m");
 | 
			
		||||
//! }
 | 
			
		||||
//! ```
 | 
			
		||||
//! And that’s it! By calling it once, you have now activated PowerShell’s and
 | 
			
		||||
//! CMD’s support for ANSI’s escaped characters on your Windows builds! And
 | 
			
		||||
//! you can leave this line in your Unix builds too, it will simply do nothing.
 | 
			
		||||
 | 
			
		||||
#[cfg(windows)]
 | 
			
		||||
pub fn init() {
 | 
			
		||||
    use winapi::shared::minwindef::DWORD;
 | 
			
		||||
@ -18,3 +42,11 @@ pub fn init() {
 | 
			
		||||
pub fn init() {
 | 
			
		||||
    ;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#[cfg(test)]
 | 
			
		||||
mod tests {
 | 
			
		||||
    #[test]
 | 
			
		||||
    fn activate_vt100() {
 | 
			
		||||
        crate::init();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user