Implement ansi support for windows 10 cmd.exe #1

Closed
opened 2022-04-08 21:07:36 +02:00 by dranke · 1 comment
Owner

see patch

see patch
Author
Owner
From d6a3aa916bca175fc31cb8a56b7ec7bde6bb83ed Mon Sep 17 00:00:00 2001
From: Dennis Ranke <dennis.ranke@gmail.com>
Date: Mon, 28 Mar 2022 22:29:45 +0200
Subject: [PATCH] enable ansi terminal on windows 10 cmd

---
 Cargo.lock  | 1 +
 Cargo.toml  | 3 ++-
 src/main.rs | 3 +++
 3 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/Cargo.lock b/Cargo.lock
index e17b649..02c0735 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2332,6 +2332,7 @@ checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9"
 name = "uw8"
 version = "0.1.2"
 dependencies = [
+ "ansi_term",
  "anyhow",
  "curlywas",
  "minifb",
diff --git a/Cargo.toml b/Cargo.toml
index 4ea7539..cd82124 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -23,4 +23,5 @@ same-file = "1"
 warp = { version = "0.3.2", optional = true }
 tokio = { version = "1.17.0", features = ["sync", "rt"], optional = true }
 tokio-stream = { version = "0.1.8", features = ["sync"], optional = true }
-webbrowser = { version = "0.6.0", optional = true }
\ No newline at end of file
+webbrowser = { version = "0.6.0", optional = true }
+ansi_term = "0.12.1"
\ No newline at end of file
diff --git a/src/main.rs b/src/main.rs
index 71d03f2..b304112 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -15,6 +15,9 @@ use uw8::Runtime;
 fn main() -> Result<()> {
     let mut args = Arguments::from_env();
 
+    // try to enable ansi support in win10 cmd shell
+    let _ = ansi_term::enable_ansi_support();
+
     match args.subcommand()?.as_deref() {
         Some("version") => {
             println!("{}", env!("CARGO_PKG_VERSION"));
-- 
2.35.1.windows.2

``` From d6a3aa916bca175fc31cb8a56b7ec7bde6bb83ed Mon Sep 17 00:00:00 2001 From: Dennis Ranke <dennis.ranke@gmail.com> Date: Mon, 28 Mar 2022 22:29:45 +0200 Subject: [PATCH] enable ansi terminal on windows 10 cmd --- Cargo.lock | 1 + Cargo.toml | 3 ++- src/main.rs | 3 +++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index e17b649..02c0735 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2332,6 +2332,7 @@ checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" name = "uw8" version = "0.1.2" dependencies = [ + "ansi_term", "anyhow", "curlywas", "minifb", diff --git a/Cargo.toml b/Cargo.toml index 4ea7539..cd82124 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,4 +23,5 @@ same-file = "1" warp = { version = "0.3.2", optional = true } tokio = { version = "1.17.0", features = ["sync", "rt"], optional = true } tokio-stream = { version = "0.1.8", features = ["sync"], optional = true } -webbrowser = { version = "0.6.0", optional = true } \ No newline at end of file +webbrowser = { version = "0.6.0", optional = true } +ansi_term = "0.12.1" \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 71d03f2..b304112 100644 --- a/src/main.rs +++ b/src/main.rs @@ -15,6 +15,9 @@ use uw8::Runtime; fn main() -> Result<()> { let mut args = Arguments::from_env(); + // try to enable ansi support in win10 cmd shell + let _ = ansi_term::enable_ansi_support(); + match args.subcommand()?.as_deref() { Some("version") => { println!("{}", env!("CARGO_PKG_VERSION")); -- 2.35.1.windows.2 ```
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: dranke/microw8#1