From b4e8793d7ccea40da275affae00446775fa752ee Mon Sep 17 00:00:00 2001 From: HampusM Date: Mon, 6 Jul 2026 22:48:31 +0200 Subject: feat: enable ANSI support on Windows --- Cargo.lock | 1 + Cargo.toml | 3 +++ src/main.rs | 8 ++++++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ed1e171..b2afe97 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -792,6 +792,7 @@ name = "game-newest" version = "0.1.0" dependencies = [ "engine", + "nu-ansi-term", "tracing", "tracing-subscriber", ] diff --git a/Cargo.toml b/Cargo.toml index dce43ca..4eaf692 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,3 +22,6 @@ tracing = { version = "0.1.39", features = ["max_level_trace", "release_max_leve [dependencies.tracing-subscriber] version = "0.3.17" features = ["env-filter", "chrono", "tracing-log"] + +[target.'cfg(windows)'.dependencies] +nu-ansi-term = "0.50.3" diff --git a/src/main.rs b/src/main.rs index 13ec797..667ac62 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,4 @@ #![cfg_attr(all(windows, not(debug_assertions)), windows_subsystem = "windows")] -use std::error::Error; use std::io::Cursor; use std::path::Path; @@ -52,8 +51,13 @@ const YELLOW: Color = Color { const RESOURCE_DIR: &str = "res"; -fn main() -> Result<(), Box> +fn main() -> Result<(), EngineError> { + #[cfg(windows)] + nu_ansi_term::enable_ansi_support() + .map_err(EngineError::from_system_defined_win32_error) + .with_context(|| "Failed to enable ANSI support")?; + tracing_subscriber::registry() .with( tracing_subscriber::fmt::layer() -- cgit v1.2.3-18-g5258