Browse Source

initial commit

master
Phuntsok Drak-pa 1 year ago
commit
b02016d8b1
3 changed files with 31 additions and 0 deletions
  1. +3
    -0
      .gitignore
  2. +9
    -0
      Cargo.toml
  3. +19
    -0
      src/lib.rs

+ 3
- 0
.gitignore View File

@@ -0,0 +1,3 @@
/target
**/*.rs.bk
Cargo.lock

+ 9
- 0
Cargo.toml View File

@@ -0,0 +1,9 @@
[package]
name = "output-vt100"
version = "0.1.0"
authors = ["Phuntsok Drak-pa <[email protected]>"]
edition = "2018"

[dependencies]
ctor = "0.1.7"
winapi = { version = "0.3.6", features = ["winuser", "winbase", "consoleapi", "processenv"] }

+ 19
- 0
src/lib.rs View File

@@ -0,0 +1,19 @@
#[cfg(windows)]
pub fn init() {
use winapi::shared::minwindef::DWORD;
use winapi::um::consoleapi::{GetConsoleMode, SetConsoleMode};
use winapi::um::processenv::GetStdHandle;
use winapi::um::winbase::STD_OUTPUT_HANDLE;
use winapi::um::wincon::{DISABLE_NEWLINE_AUTO_RETURN, ENABLE_VIRTUAL_TERMINAL_PROCESSING};

let console_out = unsafe { GetStdHandle(STD_OUTPUT_HANDLE) };

let mut state: DWORD = 0;
assert_ne!(unsafe { GetConsoleMode(console_out, &mut state) }, 0);
state |= ENABLE_VIRTUAL_TERMINAL_PROCESSING | DISABLE_NEWLINE_AUTO_RETURN;
assert_ne!(unsafe { SetConsoleMode(console_out, state) }, 0);
}
#[cfg(not(windows))]
pub fn init() {
;
}

Loading…
Cancel
Save