Skip to content

Commit

Permalink
Update winapi to 0.3
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Chris--B committed Nov 28, 2018
1 parent 8774a46 commit 2b842ab
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
14 changes: 6 additions & 8 deletions src/tty/windows.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
extern crate winapi;
extern crate kernel32;

use super::{Width, Height};

Expand All @@ -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,
Expand All @@ -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) };

Expand Down

0 comments on commit 2b842ab

Please sign in to comment.