summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsharkdp <davidpeter@web.de>2018-09-01 00:01:07 +0200
committerDavid Peter <sharkdp@users.noreply.github.com>2018-09-01 00:23:15 +0200
commit026273a05c50f9067598ffd6a58b2ad9913f7864 (patch)
treea91ad792fd5a242aa9e01ee39a035947f6b29f33
parent8903b64830a09db249d011d35e0a5537ff4ee0ba (diff)
Enable ANSI support on Windows
-rw-r--r--src/app.rs15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/app.rs b/src/app.rs
index 37fbd530..2fbe223f 100644
--- a/src/app.rs
+++ b/src/app.rs
@@ -335,6 +335,15 @@ impl App {
pub fn config(&self) -> Result<Config> {
let files = self.files();
+ let colored_output = match self.matches.value_of("color") {
+ Some("always") => true,
+ Some("never") => false,
+ Some("auto") | _ => self.interactive_output,
+ };
+
+ #[cfg(windows)]
+ let colored_output = colored_output && ansi_term::enable_ansi_support().is_ok();
+
Ok(Config {
true_color: is_truecolor_terminal(),
output_components: self.output_components()?,
@@ -349,11 +358,7 @@ impl App {
Some("never") | _ => OutputWrap::None,
}
},
- colored_output: match self.matches.value_of("color") {
- Some("always") => true,
- Some("never") => false,
- Some("auto") | _ => self.interactive_output,
- },
+ colored_output,
paging_mode: match self.matches.value_of("paging") {
Some("always") => PagingMode::Always,
Some("never") => PagingMode::Never,