Skip to content

Commit

Permalink
Enable ANSI support for Windows 10 Console
Browse files Browse the repository at this point in the history
On Windows 10, console applications must activate ANSI support in order for colors to be supported.
  • Loading branch information
zn authored and casey committed Feb 16, 2018
1 parent b7a1267 commit 9eac537
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 9eac537

Please sign in to comment.