Skip to content

Commit

Permalink
Merge pull request #79 from Chris--B/master
Browse files Browse the repository at this point in the history
Update winapi to 0.3
  • Loading branch information
a8m authored Dec 4, 2018
2 parents 8774a46 + 2b842ab commit b9792c9
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 b9792c9

Please sign in to comment.