summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2026-07-06 22:48:31 +0200
committerHampusM <hampus@hampusmat.com>2026-07-06 22:48:31 +0200
commitb4e8793d7ccea40da275affae00446775fa752ee (patch)
tree5d905e539c37221af1d36fb9ce5015eee13e0dd1
parentdadf2f2e6036dd8045ecb07f61e0d089469779f9 (diff)
feat: enable ANSI support on Windows
-rw-r--r--Cargo.lock1
-rw-r--r--Cargo.toml3
-rw-r--r--src/main.rs8
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<f32> = Color {
const RESOURCE_DIR: &str = "res";
-fn main() -> Result<(), Box<dyn Error>>
+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()