From 3a7e0f40b2ba684c3510253e37481d584192a2ec Mon Sep 17 00:00:00 2001 From: Josh McKinney Date: Sat, 22 Jun 2024 06:01:45 -0700 Subject: [PATCH] Use windows crate instead of windows-sys This avoids having to maintain code that handles errors, and various other simplifications provided by the higher level crate. From the windows crate documentation: > The windows-sys crate is a zero-overhead fallback for the most > demanding situations and primarily where the absolute best compile > time is essential. It only includes function declarations (externs), > structs, and constants. No convenience helpers, traits, or wrappers > are provided. --- Cargo.toml | 8 ++--- src/cfi.rs | 2 +- src/console.rs | 61 ++++++++++-------------------------- src/console_mode.rs | 13 ++++---- src/csbi.rs | 4 +-- src/handle.rs | 47 +++++++++++++-------------- src/lib.rs | 33 +------------------ src/screen_buffer.rs | 55 ++++++++++++++++++-------------- src/semaphore.rs | 21 ++++++++----- src/structs/coord.rs | 2 +- src/structs/input.rs | 16 ++-------- src/structs/size.rs | 2 +- src/structs/window_coords.rs | 2 +- 13 files changed, 104 insertions(+), 162 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index af284ba..ac30163 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,13 +13,11 @@ edition = "2021" rust-version = "1.60.0" [target.'cfg(windows)'.dependencies] -windows-sys = { version = "0.52.0", features = [ - "Win32_Foundation", +windows = { version = "0.57.0", features = [ "Win32_Security", - "Win32_System_Threading", - "Win32_System_Console", "Win32_Storage_FileSystem", + "Win32_System_Console", + "Win32_System_Threading", ] } - [package.metadata.docs.rs] default-target = "x86_64-pc-windows-msvc" diff --git a/src/cfi.rs b/src/cfi.rs index 7fabf1a..3f05c23 100644 --- a/src/cfi.rs +++ b/src/cfi.rs @@ -1,7 +1,7 @@ use std::fmt; use std::mem::zeroed; -use windows_sys::Win32::System::Console::CONSOLE_FONT_INFO; +use windows::Win32::System::Console::CONSOLE_FONT_INFO; use crate::Size; diff --git a/src/console.rs b/src/console.rs index 16e692e..87625d7 100644 --- a/src/console.rs +++ b/src/console.rs @@ -3,15 +3,14 @@ use std::iter; use std::slice; use std::str; -use std::ffi::c_void; -use windows_sys::Win32::System::Console::{ +use windows::Win32::System::Console::{ FillConsoleOutputAttribute, FillConsoleOutputCharacterA, GetLargestConsoleWindowSize, GetNumberOfConsoleInputEvents, ReadConsoleInputW, SetConsoleTextAttribute, - SetConsoleWindowInfo, WriteConsoleW, COORD, INPUT_RECORD, SMALL_RECT, + SetConsoleWindowInfo, WriteConsoleW, CONSOLE_CHARACTER_ATTRIBUTES, COORD, INPUT_RECORD, + SMALL_RECT, }; -const NULL: *mut c_void = 0 as *mut c_void; -use super::{result, Coord, Handle, HandleType, InputRecord, WindowPositions}; +use super::{Coord, Handle, HandleType, InputRecord, WindowPositions}; /// A wrapper around a screen buffer. #[derive(Debug, Clone)] @@ -38,7 +37,7 @@ impl Console { /// This wraps /// [`SetConsoleTextAttribute`](https://docs.microsoft.com/en-us/windows/console/setconsoletextattribute). pub fn set_text_attribute(&self, value: u16) -> Result<()> { - result(unsafe { SetConsoleTextAttribute(*self.handle, value) })?; + unsafe { SetConsoleTextAttribute(*self.handle, CONSOLE_CHARACTER_ATTRIBUTES(value)) }?; Ok(()) } @@ -47,14 +46,8 @@ impl Console { /// This wraps /// [`SetConsoleWindowInfo`](https://docs.microsoft.com/en-us/windows/console/setconsolewindowinfo). pub fn set_console_info(&self, absolute: bool, rect: WindowPositions) -> Result<()> { - let absolute = match absolute { - true => 1, - false => 0, - }; let a = SMALL_RECT::from(rect); - - result(unsafe { SetConsoleWindowInfo(*self.handle, absolute, &a) })?; - + unsafe { SetConsoleWindowInfo(*self.handle, absolute, &a) }?; Ok(()) } @@ -63,23 +56,23 @@ impl Console { /// /// This wraps /// [`FillConsoleOutputCharacterA`](https://docs.microsoft.com/en-us/windows/console/fillconsoleoutputcharacter). - pub fn fill_whit_character( + pub fn fill_with_character( &self, start_location: Coord, cells_to_write: u32, filling_char: char, ) -> Result { let mut chars_written = 0; - result(unsafe { + unsafe { // fill the cells in console with blanks FillConsoleOutputCharacterA( *self.handle, - filling_char as u8, + filling_char as i8, cells_to_write, COORD::from(start_location), &mut chars_written, ) - })?; + }?; Ok(chars_written) } @@ -97,7 +90,7 @@ impl Console { ) -> Result { let mut cells_written = 0; // Get the position of the current console window - result(unsafe { + unsafe { FillConsoleOutputAttribute( *self.handle, dw_attribute, @@ -105,7 +98,7 @@ impl Console { COORD::from(start_location), &mut cells_written, ) - })?; + }?; Ok(cells_written) } @@ -133,20 +126,9 @@ impl Console { } }; - let utf16: Vec = utf8.encode_utf16().collect(); - let utf16_ptr: *const c_void = utf16.as_ptr() as *const _ as *const c_void; + let cells_written: Option<*mut u32> = None; - let mut cells_written: u32 = 0; - - result(unsafe { - WriteConsoleW( - *self.handle, - utf16_ptr, - utf16.len() as u32, - &mut cells_written, - NULL, - ) - })?; + unsafe { WriteConsoleW(*self.handle, buf, cells_written, None) }?; Ok(utf8.as_bytes().len()) } @@ -156,7 +138,7 @@ impl Console { /// This wraps /// [`ReadConsoleInputW`](https://docs.microsoft.com/en-us/windows/console/readconsoleinput). pub fn read_single_input_event(&self) -> Result { - let mut record: INPUT_RECORD = unsafe { ::std::mem::zeroed() }; + let mut record: INPUT_RECORD = INPUT_RECORD::default(); { // Convert an INPUT_RECORD to an &mut [INPUT_RECORD] of length 1 @@ -203,7 +185,7 @@ impl Console { /// [`GetNumberOfConsoleInputEvents`](https://docs.microsoft.com/en-us/windows/console/getnumberofconsoleinputevents). pub fn number_of_console_input_events(&self) -> Result { let mut buf_len = 0; - result(unsafe { GetNumberOfConsoleInputEvents(*self.handle, &mut buf_len) })?; + unsafe { GetNumberOfConsoleInputEvents(*self.handle, &mut buf_len) }?; Ok(buf_len) } @@ -214,16 +196,7 @@ impl Console { fn read_input(&self, buf: &mut [INPUT_RECORD]) -> Result { let mut num_records = 0; debug_assert!(buf.len() < u32::MAX as usize); - - result(unsafe { - ReadConsoleInputW( - *self.handle, - buf.as_mut_ptr(), - buf.len() as u32, - &mut num_records, - ) - })?; - + unsafe { ReadConsoleInputW(*self.handle, buf, &mut num_records) }?; Ok(num_records as usize) } } diff --git a/src/console_mode.rs b/src/console_mode.rs index 5a4e487..ee71606 100644 --- a/src/console_mode.rs +++ b/src/console_mode.rs @@ -1,8 +1,8 @@ use std::io::Result; -use windows_sys::Win32::System::Console::{GetConsoleMode, SetConsoleMode}; +use windows::Win32::System::Console::{GetConsoleMode, SetConsoleMode, CONSOLE_MODE}; -use super::{result, Handle, HandleType}; +use super::{Handle, HandleType}; /// A wrapper around a screen buffer, focusing on calls to get and set the console mode. /// @@ -32,7 +32,8 @@ impl ConsoleMode { /// This wraps /// [`SetConsoleMode`](https://docs.microsoft.com/en-us/windows/console/setconsolemode). pub fn set_mode(&self, console_mode: u32) -> Result<()> { - result(unsafe { SetConsoleMode(*self.handle, console_mode) }) + unsafe { SetConsoleMode(*self.handle, CONSOLE_MODE(console_mode)) }?; + Ok(()) } /// Get the console mode. @@ -42,9 +43,9 @@ impl ConsoleMode { /// This wraps /// [`GetConsoleMode`](https://docs.microsoft.com/en-us/windows/console/getconsolemode). pub fn mode(&self) -> Result { - let mut console_mode = 0; - result(unsafe { GetConsoleMode(*self.handle, &mut console_mode) })?; - Ok(console_mode) + let mut console_mode = CONSOLE_MODE(0); + unsafe { GetConsoleMode(*self.handle, &mut console_mode) }?; + Ok(console_mode.0) } } diff --git a/src/csbi.rs b/src/csbi.rs index c1029d8..0c065fc 100644 --- a/src/csbi.rs +++ b/src/csbi.rs @@ -1,7 +1,7 @@ use std::fmt; use std::mem::zeroed; -use windows_sys::Win32::System::Console::CONSOLE_SCREEN_BUFFER_INFO; +use windows::Win32::System::Console::CONSOLE_SCREEN_BUFFER_INFO; use super::{Coord, Size, WindowPositions}; @@ -64,7 +64,7 @@ impl ScreenBufferInfo { /// /// Will take `wAttributes` from the current screen buffer. pub fn attributes(&self) -> u16 { - self.0.wAttributes + self.0.wAttributes.0 } /// Get the current column and row of the terminal cursor in the screen buffer. diff --git a/src/handle.rs b/src/handle.rs index 1221841..cc29c6b 100644 --- a/src/handle.rs +++ b/src/handle.rs @@ -2,20 +2,18 @@ use std::io::Result; use std::ops::Deref; -use std::ptr::{null, null_mut}; use std::sync::Arc; -use windows_sys::Win32::Foundation::{ - CloseHandle, GENERIC_READ, GENERIC_WRITE, HANDLE, INVALID_HANDLE_VALUE, -}; -use windows_sys::Win32::Storage::FileSystem::{ +use windows::Win32::Storage::FileSystem::{ CreateFileW, FILE_SHARE_READ, FILE_SHARE_WRITE, OPEN_EXISTING, }; -use windows_sys::Win32::System::Console::{ +use windows::Win32::System::Console::{ GetStdHandle, STD_HANDLE, STD_INPUT_HANDLE, STD_OUTPUT_HANDLE, }; - -use super::handle_result; +use windows::Win32::{ + Foundation::{CloseHandle, GENERIC_READ, GENERIC_WRITE, HANDLE, INVALID_HANDLE_VALUE}, + Storage::FileSystem::FILE_FLAGS_AND_ATTRIBUTES, +}; /// The standard handles of a process. /// @@ -65,7 +63,7 @@ impl Drop for Inner { fn drop(&mut self) { if self.is_exclusive { assert!( - unsafe { CloseHandle(self.handle) != 0 }, + unsafe { CloseHandle(self.handle).is_ok() }, "failed to close handle" ) } @@ -115,17 +113,17 @@ impl Handle { /// This wraps /// [`CreateFileW`](https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilew). pub fn current_out_handle() -> Result { - let handle = handle_result(unsafe { + let handle = unsafe { CreateFileW( - ::windows_sys::w!("CONOUT$"), - GENERIC_READ | GENERIC_WRITE, + ::windows::core::w!("CONOUT$"), + (GENERIC_READ | GENERIC_WRITE).0, FILE_SHARE_READ | FILE_SHARE_WRITE, - null(), + None, // no security attributes OPEN_EXISTING, - 0, - 0, + FILE_FLAGS_AND_ATTRIBUTES::default(), + None, // no template file ) - })?; + }?; Ok(Handle { handle: Arc::new(Inner::new_exclusive(handle)), @@ -139,17 +137,17 @@ impl Handle { /// This wraps /// [`CreateFileW`](https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilew). pub fn current_in_handle() -> Result { - let handle = handle_result(unsafe { + let handle = unsafe { CreateFileW( - ::windows_sys::w!("CONIN$"), - GENERIC_READ | GENERIC_WRITE, + ::windows::core::w!("CONIN$"), + (GENERIC_READ | GENERIC_WRITE).0, FILE_SHARE_READ | FILE_SHARE_WRITE, - null_mut(), + None, // no security attributes OPEN_EXISTING, - 0, - 0, + FILE_FLAGS_AND_ATTRIBUTES::default(), + None, // no template file ) - })?; + }?; Ok(Handle { handle: Arc::new(Inner::new_exclusive(handle)), @@ -177,8 +175,7 @@ impl Handle { } fn std_handle(which_std: STD_HANDLE) -> Result { - let handle = handle_result(unsafe { GetStdHandle(which_std) })?; - + let handle = unsafe { GetStdHandle(which_std) }?; Ok(Handle { handle: Arc::new(Inner::new_shared(handle)), }) diff --git a/src/lib.rs b/src/lib.rs index 0065e55..f55de5b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,8 +3,7 @@ use std::io; -use windows_sys::Win32::Foundation::{BOOL, HANDLE, INVALID_HANDLE_VALUE}; -use windows_sys::Win32::System::Console::COORD; +use windows::Win32::System::Console::COORD; pub use self::{ cfi::FontInfo, @@ -29,16 +28,6 @@ mod screen_buffer; mod semaphore; mod structs; -/// Get the result of a call to WinAPI as an [`io::Result`]. -#[inline] -pub fn result(return_value: BOOL) -> io::Result<()> { - if return_value != 0 { - Ok(()) - } else { - Err(io::Error::last_os_error()) - } -} - /// Get the result of a call to WinAPI that returns a /// [`COORD`](https://docs.microsoft.com/en-us/windows/console/coord-str) as an [`io::Result`]. #[inline] @@ -49,23 +38,3 @@ pub fn coord_result(return_value: COORD) -> io::Result { Err(io::Error::last_os_error()) } } - -/// Get the result of a call to WinAPI that returns a handle or `INVALID_HANDLE_VALUE`. -#[inline] -pub fn handle_result(return_value: HANDLE) -> io::Result { - if return_value != INVALID_HANDLE_VALUE { - Ok(return_value) - } else { - Err(io::Error::last_os_error()) - } -} - -/// Get the result of a call to WinAPI that returns a handle or `NULL`. -#[inline] -pub fn nonnull_handle_result(return_value: HANDLE) -> io::Result { - if return_value == 0 { - Err(io::Error::last_os_error()) - } else { - Ok(return_value) - } -} diff --git a/src/screen_buffer.rs b/src/screen_buffer.rs index 11a399b..159e7a5 100644 --- a/src/screen_buffer.rs +++ b/src/screen_buffer.rs @@ -3,18 +3,17 @@ use std::io::Result; use std::mem::size_of; -use windows_sys::Win32::System::Console::{ - CreateConsoleScreenBuffer, GetConsoleScreenBufferInfo, SetConsoleActiveScreenBuffer, - SetConsoleScreenBufferSize, CONSOLE_TEXTMODE_BUFFER, COORD, -}; -use windows_sys::Win32::{ +use windows::Win32::{ Foundation::{GENERIC_READ, GENERIC_WRITE}, + Security::SECURITY_ATTRIBUTES, Storage::FileSystem::{FILE_SHARE_READ, FILE_SHARE_WRITE}, + System::Console::{ + CreateConsoleScreenBuffer, GetConsoleScreenBufferInfo, GetCurrentConsoleFont, + SetConsoleActiveScreenBuffer, SetConsoleScreenBufferSize, CONSOLE_TEXTMODE_BUFFER, COORD, + }, }; -use windows_sys::Win32::{Security::SECURITY_ATTRIBUTES, System::Console::GetCurrentConsoleFont}; -pub const TRUE: ::windows_sys::Win32::Foundation::BOOL = 1; -use super::{handle_result, result, FontInfo, Handle, HandleType, ScreenBufferInfo}; +use super::{FontInfo, Handle, HandleType, ScreenBufferInfo}; /// A wrapper around a screen buffer. #[derive(Clone, Debug)] @@ -43,18 +42,18 @@ impl ScreenBuffer { let security_attr: SECURITY_ATTRIBUTES = SECURITY_ATTRIBUTES { nLength: size_of::() as u32, lpSecurityDescriptor: ::std::ptr::null_mut(), - bInheritHandle: TRUE, + bInheritHandle: true.into(), }; - let new_screen_buffer = handle_result(unsafe { + let new_screen_buffer = unsafe { CreateConsoleScreenBuffer( - GENERIC_READ | GENERIC_WRITE, // read/write access - FILE_SHARE_READ | FILE_SHARE_WRITE, // shared - &security_attr, // default security attributes - CONSOLE_TEXTMODE_BUFFER, // must be TEXTMODE - ::std::ptr::null_mut(), - ) as _ - })?; + (GENERIC_READ | GENERIC_WRITE).0, // read/write access + (FILE_SHARE_READ | FILE_SHARE_WRITE).0, // shared + Some(&security_attr), // security attributes + CONSOLE_TEXTMODE_BUFFER, // must be TEXTMODE + None, // no existing screen buffer to copy + ) + }?; Ok(ScreenBuffer { handle: unsafe { Handle::from_raw(new_screen_buffer) }, }) @@ -65,7 +64,8 @@ impl ScreenBuffer { /// This wraps /// [`SetConsoleActiveScreenBuffer`](https://docs.microsoft.com/en-us/windows/console/setconsoleactivescreenbuffer). pub fn show(&self) -> Result<()> { - result(unsafe { SetConsoleActiveScreenBuffer(*self.handle) }) + unsafe { SetConsoleActiveScreenBuffer(*self.handle) }?; + Ok(()) } /// Get the screen buffer information like terminal size, cursor position, buffer size. @@ -74,18 +74,24 @@ impl ScreenBuffer { /// [`GetConsoleScreenBufferInfo`](https://docs.microsoft.com/en-us/windows/console/getconsolescreenbufferinfo). pub fn info(&self) -> Result { let mut csbi = ScreenBufferInfo::new(); - result(unsafe { GetConsoleScreenBufferInfo(*self.handle, &mut csbi.0) })?; + unsafe { GetConsoleScreenBufferInfo(*self.handle, &mut csbi.0) }?; Ok(csbi) } /// Get the current font information like size and font index. /// /// This wraps - /// [`GetConsoleFontSize`](https://learn.microsoft.com/en-us/windows/console/getconsolefontsize). + /// [`GetCurrentConsoleFont`](https://learn.microsoft.com/en-us/windows/console/getcurrentconsolefont). pub fn font_info(&self) -> Result { - let mut fi = FontInfo::new(); - result(unsafe { GetCurrentConsoleFont(*self.handle, 0, &mut fi.0) })?; - Ok(fi) + let mut font_info = FontInfo::new(); + unsafe { + GetCurrentConsoleFont( + *self.handle, + false, // get info for current window size not the maximum window size + &mut font_info.0, + ) + }?; + Ok(font_info) } /// Set the console screen buffer size to the given size. @@ -93,7 +99,8 @@ impl ScreenBuffer { /// This wraps /// [`SetConsoleScreenBufferSize`](https://docs.microsoft.com/en-us/windows/console/setconsolescreenbuffersize). pub fn set_size(&self, x: i16, y: i16) -> Result<()> { - result(unsafe { SetConsoleScreenBufferSize(*self.handle, COORD { X: x, Y: y }) }) + unsafe { SetConsoleScreenBufferSize(*self.handle, COORD { X: x, Y: y }) }?; + Ok(()) } /// Get the underlying raw `HANDLE` used by this type to execute with. diff --git a/src/semaphore.rs b/src/semaphore.rs index 12a3f72..ba36997 100644 --- a/src/semaphore.rs +++ b/src/semaphore.rs @@ -1,8 +1,8 @@ -use std::{io, ptr}; +use std::io; -use windows_sys::Win32::System::Threading::{CreateSemaphoreW, ReleaseSemaphore}; +use windows::Win32::System::Threading::{CreateSemaphoreW, ReleaseSemaphore}; -use crate::{nonnull_handle_result, result, Handle}; +use crate::Handle; /// A [Windows semaphore](https://docs.microsoft.com/en-us/windows/win32/sync/semaphore-objects). #[derive(Clone, Debug)] @@ -14,9 +14,14 @@ impl Semaphore { /// This wraps /// [`CreateSemaphoreW`](https://docs.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-createsemaphorew). pub fn new() -> io::Result { - let handle = - nonnull_handle_result(unsafe { CreateSemaphoreW(ptr::null(), 0, 1, ptr::null()) })?; - + let handle = unsafe { + CreateSemaphoreW( + None, // no security attributes + 0, // initial count + 1, // maximum count + windows::core::w!(""), // unnamed semaphore + ) + }?; let handle = unsafe { Handle::from_raw(handle) }; Ok(Self(handle)) } @@ -26,7 +31,9 @@ impl Semaphore { /// This wraps /// [`ReleaseSemaphore`](https://docs.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-releasesemaphore). pub fn release(&self) -> io::Result<()> { - result(unsafe { ReleaseSemaphore(*self.0, 1, ptr::null_mut()) }) + let previous_count = None; + unsafe { ReleaseSemaphore(*self.0, 1, previous_count) }?; + Ok(()) } /// Access the underlying handle to the semaphore. diff --git a/src/structs/coord.rs b/src/structs/coord.rs index 90fafff..6d77ff5 100644 --- a/src/structs/coord.rs +++ b/src/structs/coord.rs @@ -2,7 +2,7 @@ //! For example, in WinAPI we have `COORD` which looks and feels inconvenient. //! This module provides also some trait implementations who will make parsing and working with `COORD` easier. -use windows_sys::Win32::System::Console::COORD; +use windows::Win32::System::Console::COORD; /// This is type represents the position of something on a certain 'x' and 'y'. #[derive(Copy, Clone, Debug, Default, Eq, PartialEq, PartialOrd)] diff --git a/src/structs/input.rs b/src/structs/input.rs index ad5f316..15dcb6c 100644 --- a/src/structs/input.rs +++ b/src/structs/input.rs @@ -9,7 +9,7 @@ //! - `InputEventType` //! - `INPUT_RECORD` -use windows_sys::Win32::System::Console::{ +use windows::Win32::System::Console::{ FOCUS_EVENT, FOCUS_EVENT_RECORD, FROM_LEFT_1ST_BUTTON_PRESSED, FROM_LEFT_2ND_BUTTON_PRESSED, FROM_LEFT_3RD_BUTTON_PRESSED, FROM_LEFT_4TH_BUTTON_PRESSED, INPUT_RECORD, KEY_EVENT, KEY_EVENT_RECORD, MENU_EVENT, MENU_EVENT_RECORD, MOUSE_EVENT, MOUSE_EVENT_RECORD, @@ -50,7 +50,7 @@ impl KeyEventRecord { #[inline] fn from_winapi(record: &KEY_EVENT_RECORD) -> Self { KeyEventRecord { - key_down: record.bKeyDown != 0, + key_down: record.bKeyDown.as_bool(), repeat_count: record.wRepeatCount, virtual_key_code: record.wVirtualKeyCode, virtual_scan_code: record.wVirtualScanCode, @@ -163,16 +163,6 @@ impl ButtonState { self.state > 0 } - /// Returns whether there is a horizontal scroll to the right. - pub fn scroll_right(&self) -> bool { - self.state > 0 - } - - /// Returns whether there is a horizontal scroll to the left. - pub fn scroll_left(&self) -> bool { - self.state < 0 - } - /// Returns the raw state. pub fn state(&self) -> i32 { self.state @@ -268,7 +258,7 @@ impl From for FocusEventRecord { #[inline] fn from(record: FOCUS_EVENT_RECORD) -> Self { FocusEventRecord { - set_focus: record.bSetFocus != 0, + set_focus: record.bSetFocus.as_bool(), } } } diff --git a/src/structs/size.rs b/src/structs/size.rs index 697edda..56ae98a 100644 --- a/src/structs/size.rs +++ b/src/structs/size.rs @@ -2,7 +2,7 @@ //! For example, in WinAPI we have `COORD` to represent screen/buffer size but this is a little inconvenient. //! This module provides some trait implementations who will make parsing and working with `COORD` easier. -use windows_sys::Win32::System::Console::COORD; +use windows::Win32::System::Console::COORD; /// This is type represents the size of something in width and height. #[derive(Copy, Clone, Debug, Default, Eq, PartialEq)] diff --git a/src/structs/window_coords.rs b/src/structs/window_coords.rs index a2f1e17..9ec1c10 100644 --- a/src/structs/window_coords.rs +++ b/src/structs/window_coords.rs @@ -2,7 +2,7 @@ //! For example, in WinAPI we have `SMALL_RECT` to represent a window size but this is a little inconvenient. //! This module provides some trait implementations who will make parsing and working with `SMALL_RECT` easier. -use windows_sys::Win32::System::Console::{CONSOLE_SCREEN_BUFFER_INFO, SMALL_RECT}; +use windows::Win32::System::Console::{CONSOLE_SCREEN_BUFFER_INFO, SMALL_RECT}; /// This is a wrapper for the locations of a rectangle. #[derive(Copy, Clone, Debug, Default, Eq, PartialEq)]