From 9eac537a01af771fd97f6d8393e764dc14e61739 Mon Sep 17 00:00:00 2001 From: Gaeulbyul Date: Fri, 16 Feb 2018 17:52:00 +0900 Subject: [PATCH] Enable ANSI support for Windows 10 Console On Windows 10, console applications must activate ANSI support in order for colors to be supported. --- src/run.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/run.rs b/src/run.rs index 0684766..35aa65a 100644 --- a/src/run.rs +++ b/src/run.rs @@ -2,10 +2,13 @@ use common::*; use std::{convert, ffi, cmp}; use clap::{App, Arg, ArgGroup, AppSettings}; -use misc::maybe_s; use configuration::DEFAULT_SHELL; +use misc::maybe_s; use unicode_width::UnicodeWidthStr; +#[cfg(windows)] +use ansi_term::enable_ansi_support; + macro_rules! die { ($($arg:tt)*) => {{ extern crate std; @@ -132,6 +135,11 @@ pub fn run() { other => die!("Invalid argument `{}` to --color. This is a bug in just.", other), }; + if color.active() { + #[cfg(windows)] + enable_ansi_support().ok(); + } + let set_count = matches.occurrences_of("SET"); let mut overrides = Map::new(); if set_count > 0 {