Skip to content

Commit

Permalink
Fixed ANSI codes when running standalone
Browse files Browse the repository at this point in the history
  • Loading branch information
grufkork committed Feb 16, 2021
1 parent ef3aecc commit 6c8ad88
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
12 changes: 11 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
[package]
name = "scpmapper"
version = "1.0.0"
version = "1.0.1"
authors = ["grufkork <griffin.hiscoke@me.com>"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
inputbot = "0.5.0"
inputbot = "0.5.0"

[target.'cfg(windows)'.dependencies]
winapi-util = "0.1.5"
15 changes: 14 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ struct Layout{
}

fn main() {
println!("scpmapper v1.0.0");
enable_virtual_terminal_processing();
println!("scpmapper v1.0.1");

let loop_time = Duration::from_millis(33);

Expand Down Expand Up @@ -354,4 +355,16 @@ fn zone_to_string(zone: Zone) -> String{
Zone::Light => "light".to_string(),
Zone::Heavy => "heavy".to_string()
}
}

#[cfg(windows)]
pub fn enable_virtual_terminal_processing() {
use winapi_util::console::Console;

if let Ok(mut term) = Console::stdout() {
let _ = term.set_virtual_terminal_processing(true);
}
if let Ok(mut term) = Console::stderr() {
let _ = term.set_virtual_terminal_processing(true);
}
}

0 comments on commit 6c8ad88

Please sign in to comment.