Skip to content

Commit

Permalink
Cargo fmt on latest build
Browse files Browse the repository at this point in the history
  • Loading branch information
nidnogg committed Feb 6, 2024
1 parent d4dde8f commit 6c5bada
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
3 changes: 1 addition & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ use sysinfo::{System, SystemExt};
mod ansi;
mod cli;
mod logo;
mod scanner;
mod platform_util;
mod scanner;

fn main() -> Result<(), Box<dyn std::error::Error>> {

let ctx = cli::Ctx::new();
generate_info(&ctx)?;

Expand Down
16 changes: 10 additions & 6 deletions src/platform_util.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
// Windows doesn't always have ANSI color processing enabled by default.
// This function attempts to safely force-enable it.
pub fn enforce_ansi_windows() -> bool {
#[cfg(windows)] {
#[cfg(windows)]
{
if cfg!(target_os = "windows") {
use winapi::um::wincon::ENABLE_VIRTUAL_TERMINAL_PROCESSING;
use winapi::um::winbase::STD_OUTPUT_HANDLE;
use winapi::um::processenv::GetStdHandle;
use winapi::um::consoleapi::{GetConsoleMode, SetConsoleMode};
use winapi::um::processenv::GetStdHandle;
use winapi::um::winbase::STD_OUTPUT_HANDLE;
use winapi::um::wincon::ENABLE_VIRTUAL_TERMINAL_PROCESSING;

unsafe {
let console_handle = GetStdHandle(STD_OUTPUT_HANDLE);
Expand All @@ -20,12 +21,15 @@ pub fn enforce_ansi_windows() -> bool {
return false;
}

if 0 == SetConsoleMode(console_handle, current_mode | ENABLE_VIRTUAL_TERMINAL_PROCESSING) {
if 0 == SetConsoleMode(
console_handle,
current_mode | ENABLE_VIRTUAL_TERMINAL_PROCESSING,
) {
return false;
}
}
}
}

true
}
}

0 comments on commit 6c5bada

Please sign in to comment.