Fix enabling ANSI support when stdout is redirected. (#497)

This commit is contained in:
David Sherret 2020-10-10 16:03:12 -04:00 committed by GitHub
parent efb06b8baa
commit 4b1c857914
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,4 +1,4 @@
use crossterm_winapi::ConsoleMode; use crossterm_winapi::{ConsoleMode, Handle};
use winapi::um::wincon::ENABLE_VIRTUAL_TERMINAL_PROCESSING; use winapi::um::wincon::ENABLE_VIRTUAL_TERMINAL_PROCESSING;
use lazy_static::lazy_static; use lazy_static::lazy_static;
@ -17,7 +17,7 @@ use crate::Result;
pub(crate) fn set_virtual_terminal_processing(yes: bool) -> Result<()> { pub(crate) fn set_virtual_terminal_processing(yes: bool) -> Result<()> {
let mask = ENABLE_VIRTUAL_TERMINAL_PROCESSING; let mask = ENABLE_VIRTUAL_TERMINAL_PROCESSING;
let console_mode = ConsoleMode::new()?; let console_mode = ConsoleMode::from(Handle::current_out_handle()?);
let old_mode = console_mode.mode()?; let old_mode = console_mode.mode()?;
let new_mode = if yes { let new_mode = if yes {