mirror of
https://github.com/BurntSushi/ripgrep.git
synced 2025-03-03 14:32:22 +02:00
The primary motivation for this commit was rust-lang/cargo#4189 where dropping a `wincolor::Console` would call `CloseHandle` to close the console handle. Cargo creates a few `Console` instances so it ended up closing stdout a little earlier as intended! The `GetStdHandle` function returns handles I believe aren't intended to be closed (as there's no refcounting). I believe libstd doesn't close these handles. This commit also moves to calling `GetStdHandle` on demand which libstd changed to doing so recently as well, preventing caching of stale handles that change over time with calls to `SetStdHandle`.
wincolor
A simple Windows specific API for controlling text color in a Windows console. The purpose of this crate is to expose the full inflexibility of the Windows console without any platform independent abstraction.
Dual-licensed under MIT or the UNLICENSE.
Documentation
Usage
Add this to your Cargo.toml
:
[dependencies]
wincolor = "0.1"
and this to your crate root:
extern crate wincolor;
Example
This is a simple example that shows how to write text with a foreground color of cyan and the intense attribute set:
use wincolor::{Console, Color, Intense};
let mut con = Console::stdout().unwrap();
con.fg(Intense::Yes, Color::Cyan).unwrap();
println!("This text will be intense cyan.");
con.reset().unwrap();
println!("This text will be normal.");