Skip to content

Commit a8c8bd9

Browse files
committed
fix windows color (adding color for later Win10 versions)
.# Discussion This fixes Windows color support, turning it off when not supported, and enabling Win10 display of color when possible. The code enabling support will likely work, but may be subject to change or improvement when [colored/PR#47](colored-rs/colored#47) is merged.
1 parent ff75906 commit a8c8bd9

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

Diff for: Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ num_cpus = "1.8.0"
3434
pad = "0.1.4"
3535
walkdir = "2.1.3"
3636
regex = "1.0"
37+
ansi_term = "0.11.0"
3738

3839
[dependencies.clap]
3940
features = ["yaml"]

Diff for: src/main.rs

+12
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#[macro_use]
22
extern crate clap;
33

4+
#[cfg(target = "windows")]
5+
extern crate ansi_term;
6+
47
extern crate colored;
58
extern crate liboskar;
69

@@ -28,6 +31,15 @@ fn main() {
2831
.setting(AppSettings::SubcommandRequired)
2932
.get_matches();
3033

34+
#[cfg(not(target = "windows"))]
35+
let color_ok = true;
36+
#[cfg(target = "windows")]
37+
let color_ok = !ansi_term::enable_ansi_support().is_ok();
38+
39+
if !color_ok {
40+
colored::control::set_override(false);
41+
}
42+
3143
// TODO this should install manpages?
3244
if let Some(x) = matches.subcommand_matches("update") {
3345
let force = x.is_present("force");

0 commit comments

Comments
 (0)