Enable ANSI support for Windows 10 Console

On Windows 10, console applications must activate ANSI support in order for colors to be supported.
This commit is contained in:
Gaeulbyul 2018-02-16 17:52:00 +09:00 committed by Casey Rodarmor
parent b7a126742f
commit 9eac537a01

View File

@ -2,10 +2,13 @@ use common::*;
use std::{convert, ffi, cmp}; use std::{convert, ffi, cmp};
use clap::{App, Arg, ArgGroup, AppSettings}; use clap::{App, Arg, ArgGroup, AppSettings};
use misc::maybe_s;
use configuration::DEFAULT_SHELL; use configuration::DEFAULT_SHELL;
use misc::maybe_s;
use unicode_width::UnicodeWidthStr; use unicode_width::UnicodeWidthStr;
#[cfg(windows)]
use ansi_term::enable_ansi_support;
macro_rules! die { macro_rules! die {
($($arg:tt)*) => {{ ($($arg:tt)*) => {{
extern crate std; extern crate std;
@ -132,6 +135,11 @@ pub fn run() {
other => die!("Invalid argument `{}` to --color. This is a bug in just.", other), 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 set_count = matches.occurrences_of("SET");
let mut overrides = Map::new(); let mut overrides = Map::new();
if set_count > 0 { if set_count > 0 {