From 2b842aba24e6c89909d67be3a1c93faf692ab5d4 Mon Sep 17 00:00:00 2001 From: Chris Butler Date: Wed, 28 Nov 2018 11:34:36 -0500 Subject: [PATCH] Update winapi to 0.3 This updates the winapi crate to 0.3, which re-organizes its modules and removes the need for kernal32-sys. More and more crates are using v0.3, and this allows better reuse in larger dependency graphs. --- Cargo.toml | 6 +++--- src/tty/windows.rs | 14 ++++++-------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ce56af8e..8f41e440 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,9 +12,9 @@ license = "MIT" libc = "0.2" time = "0.1.35" -[target.'cfg(target_os = "windows")'.dependencies] -winapi = "0.2" -kernel32-sys = "0.2" +[target.'cfg(target_os = "windows")'.dependencies.winapi] +version = "0.3" +features = ["wincon", "processenv", "winbase"] [target.'cfg(target_os = "redox")'.dependencies] termion = "1.4" diff --git a/src/tty/windows.rs b/src/tty/windows.rs index e7cc6f33..27647ae3 100644 --- a/src/tty/windows.rs +++ b/src/tty/windows.rs @@ -1,5 +1,4 @@ extern crate winapi; -extern crate kernel32; use super::{Width, Height}; @@ -20,8 +19,7 @@ pub fn terminal_size() -> Option<(Width, Height)> { /// move the cursor `n` lines up; return an empty string, just to /// be aligned with the unix version. pub fn move_cursor_up(n: usize) -> String { - use self::kernel32::SetConsoleCursorPosition; - use self::winapi::COORD; + use self::winapi::um::wincon::{SetConsoleCursorPosition, COORD}; if let Some((hand, csbi)) = get_csbi() { unsafe { SetConsoleCursorPosition(hand, @@ -34,11 +32,11 @@ pub fn move_cursor_up(n: usize) -> String { "".to_string() } -fn get_csbi() -> Option<(self::winapi::HANDLE, self::winapi::CONSOLE_SCREEN_BUFFER_INFO)> { - use self::winapi::HANDLE; - use self::kernel32::{GetStdHandle, GetConsoleScreenBufferInfo}; - use self::winapi::STD_OUTPUT_HANDLE; - use self::winapi::{CONSOLE_SCREEN_BUFFER_INFO, COORD, SMALL_RECT}; +fn get_csbi() -> Option<(self::winapi::shared::ntdef::HANDLE, self::winapi::um::wincon::CONSOLE_SCREEN_BUFFER_INFO)> { + use self::winapi::shared::ntdef::HANDLE; + use self::winapi::um::processenv::GetStdHandle; + use self::winapi::um::winbase::STD_OUTPUT_HANDLE; + use self::winapi::um::wincon::{GetConsoleScreenBufferInfo, CONSOLE_SCREEN_BUFFER_INFO, COORD, SMALL_RECT}; let hand: HANDLE = unsafe { GetStdHandle(STD_OUTPUT_HANDLE) };