From b847d1630728ef18f273abd0b6ca7cd471c47652 Mon Sep 17 00:00:00 2001 From: Atsukoro1 Date: Mon, 5 Dec 2022 22:52:08 +0100 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20Code=20style?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/helpers/colors.rs | 31 +++++++++++++++++++++++++++++-- src/helpers/console.rs | 26 -------------------------- src/helpers/mod.rs | 3 +-- 3 files changed, 30 insertions(+), 30 deletions(-) delete mode 100644 src/helpers/console.rs diff --git a/src/helpers/colors.rs b/src/helpers/colors.rs index 0b3f0b1..15ad6ab 100644 --- a/src/helpers/colors.rs +++ b/src/helpers/colors.rs @@ -1,5 +1,3 @@ -use crate::helpers::console::enable_ansi_support; - pub const COLORS : [(&str, &str); 34] = [ ("black", "\u{001b}[30m"), ("red", "\u{001b}[31m"), @@ -37,6 +35,35 @@ pub const COLORS : [(&str, &str); 34] = [ ("bright_white_bold", "\u{001b}[97m\u{001b}[1m"), ]; +#[cfg(target_os = "windows")] +fn enable_ansi_support() { + { + use std::os::windows::prelude::AsRawHandle; + + const ENABLE_V_TERM_PROCESSING: u32 = 0x0004; + + let stdout = std::io::stdout(); + let handle = stdout.lock(); + + let mut mode = 0; + + unsafe { + let handle = handle.as_raw_handle(); + let result = kernel32::GetConsoleMode(handle, &mut mode); + if result == 0 { + return; + } + + mode |= ENABLE_V_TERM_PROCESSING; + + let result = kernel32::SetConsoleMode(handle, mode); + if result == 0 { + return; + } + } + } +} + pub fn print(text: &str, inline: bool, color: &str) { let color = COLORS.iter().find( |(name, _)| name == &color diff --git a/src/helpers/console.rs b/src/helpers/console.rs deleted file mode 100644 index af2208e..0000000 --- a/src/helpers/console.rs +++ /dev/null @@ -1,26 +0,0 @@ -#[cfg(target_os = "windows")] -pub fn enable_ansi_support() { - use std::os::windows::prelude::AsRawHandle; - - const ENABLE_V_TERM_PROCESSING: u32 = 0x0004; - - let stdout = std::io::stdout(); - let handle = stdout.lock(); - - let mut mode = 0; - - unsafe { - let handle = handle.as_raw_handle(); - let result = kernel32::GetConsoleMode(handle, &mut mode); - if result == 0 { - return; - } - - mode |= ENABLE_V_TERM_PROCESSING; - - let result = kernel32::SetConsoleMode(handle, mode); - if result == 0 { - return; - } - } -} \ No newline at end of file diff --git a/src/helpers/mod.rs b/src/helpers/mod.rs index 7952e51..2ad3c2f 100644 --- a/src/helpers/mod.rs +++ b/src/helpers/mod.rs @@ -3,5 +3,4 @@ pub mod file; pub mod colors; pub mod print; pub mod paths; -pub mod ponies; -pub mod console; \ No newline at end of file +pub mod ponies; \ No newline at end of file