Skip to content

Commit f1e593b

Browse files
LingManhwittenborn
authored andcommitted
Switch from winapi to windows-sys
`winapi` is being phased out across the ecosystem in favor of `windows-sys`, which is maintained by Microsoft. Let's follow suit so dependents don't have to compile both.
1 parent e20bd92 commit f1e593b

File tree

3 files changed

+8
-17
lines changed

3 files changed

+8
-17
lines changed

Cargo.toml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,11 @@ no-color = []
1919
is-terminal = "0.4"
2020
lazy_static = "1"
2121

22-
[target.'cfg(windows)'.dependencies.winapi]
23-
version = "0.3"
24-
default-features = false
22+
[target.'cfg(windows)'.dependencies.windows-sys]
23+
version = "0.48"
2524
features = [
26-
"consoleapi",
27-
"processenv",
28-
"winbase"
25+
"Win32_Foundation",
26+
"Win32_System_Console",
2927
]
3028

3129
[dev_dependencies]

src/control.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,14 @@ use std::sync::atomic::{AtomicBool, Ordering};
2929
#[allow(clippy::result_unit_err)]
3030
#[cfg(windows)]
3131
pub fn set_virtual_terminal(use_virtual: bool) -> Result<(), ()> {
32-
use winapi::{
33-
shared::minwindef::DWORD,
34-
um::{
35-
consoleapi::{GetConsoleMode, SetConsoleMode},
36-
processenv::GetStdHandle,
37-
winbase::STD_OUTPUT_HANDLE,
38-
wincon::ENABLE_VIRTUAL_TERMINAL_PROCESSING,
39-
},
32+
use windows_sys::Win32::System::Console::{
33+
GetConsoleMode, GetStdHandle, SetConsoleMode, ENABLE_VIRTUAL_TERMINAL_PROCESSING,
34+
STD_OUTPUT_HANDLE,
4035
};
4136

4237
unsafe {
4338
let handle = GetStdHandle(STD_OUTPUT_HANDLE);
44-
let mut original_mode: DWORD = 0;
39+
let mut original_mode = 0;
4540
GetConsoleMode(handle, &mut original_mode);
4641

4742
let enabled = original_mode & ENABLE_VIRTUAL_TERMINAL_PROCESSING

src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828
extern crate is_terminal;
2929
#[macro_use]
3030
extern crate lazy_static;
31-
#[cfg(windows)]
32-
extern crate winapi;
3331

3432
#[cfg(test)]
3533
extern crate rspec;

0 commit comments

Comments
 (0)