Skip to content

Commit 6ee73cd

Browse files
author
char0313
committed
Change from using the unofficial winapi bindings, to using the official windows bindings from Microsoft.
1 parent 29af880 commit 6ee73cd

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ colored = { version = "2", optional = true }
2222

2323
[target.'cfg(windows)'.dependencies]
2424
atty = "0.2.13"
25-
winapi = { version = "0.3", features = ["handleapi", "winbase"]}
25+
windows-sys = { version = "0.42.0", features = ["Win32_System_Console", "Win32_Foundation"] }
2626

2727
[[example]]
2828
name = "colors"

src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -468,19 +468,19 @@ fn set_up_color_terminal() {
468468

469469
if atty::is(Stream::Stdout) {
470470
unsafe {
471-
use winapi::um::consoleapi::*;
472-
use winapi::um::handleapi::*;
473-
use winapi::um::processenv::*;
474-
use winapi::um::winbase::*;
475-
use winapi::um::wincon::*;
471+
use windows_sys::Win32::Foundation::INVALID_HANDLE_VALUE;
472+
use windows_sys::Win32::System::Console::{
473+
GetConsoleMode, GetStdHandle, SetConsoleMode, CONSOLE_MODE,
474+
ENABLE_VIRTUAL_TERMINAL_PROCESSING, STD_OUTPUT_HANDLE,
475+
};
476476

477477
let stdout = GetStdHandle(STD_OUTPUT_HANDLE);
478478

479479
if stdout == INVALID_HANDLE_VALUE {
480480
return;
481481
}
482482

483-
let mut mode: winapi::shared::minwindef::DWORD = 0;
483+
let mut mode: CONSOLE_MODE = 0;
484484

485485
if GetConsoleMode(stdout, &mut mode) == 0 {
486486
return;

0 commit comments

Comments
 (0)