diff --git a/crossterm_input/src/input/windows_input.rs b/crossterm_input/src/input/windows_input.rs index ba9cdc7d5..91447cd4f 100644 --- a/crossterm_input/src/input/windows_input.rs +++ b/crossterm_input/src/input/windows_input.rs @@ -1,11 +1,9 @@ //! This is a WINDOWS specific implementation for input related action. -use super::*; - -use crossterm_winapi::{ - ButtonState, Console, ConsoleMode, EventFlags, Handle, InputEventType, KeyEventRecord, - MouseEvent, -}; +use std::sync::atomic::{AtomicBool, Ordering}; +use std::sync::mpsc; +use std::time::Duration; +use std::{char, io, thread}; use winapi::um::{ wincon::{ @@ -19,10 +17,12 @@ use winapi::um::{ }, }; -use std::sync::atomic::{AtomicBool, Ordering}; -use std::sync::mpsc; -use std::time::Duration; -use std::{char, io, thread}; +use crossterm_winapi::{ + ButtonState, Console, ConsoleMode, EventFlags, Handle, InputEventType, KeyEventRecord, + MouseEvent, +}; + +use super::*; pub struct WindowsInput; @@ -157,7 +157,7 @@ pub struct AsyncReader { impl AsyncReader { /// Construct a new instance of the `AsyncReader`. /// The reading will immediately start when calling this function. - pub fn new(function: Box, &Arc) + Send>) -> AsyncReader { + pub fn new(function: Box, &Arc) + Send>) -> AsyncReader { let shutdown_handle = Arc::new(AtomicBool::new(false)); let (event_tx, event_rx) = mpsc::channel(); @@ -383,10 +383,10 @@ fn parse_key_event_record(key_event: &KeyEventRecord) -> Option { } } else if key_state.has_state(LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED) { match character_raw as u8 { - c @ b'\x01'...b'\x1A' => { + c @ b'\x01'..=b'\x1A' => { Some(KeyEvent::Ctrl((c as u8 - 0x1 + b'a') as char)) } - c @ b'\x1C'...b'\x1F' => { + c @ b'\x1C'..=b'\x1F' => { Some(KeyEvent::Ctrl((c as u8 - 0x1C + b'4') as char)) } _ => None, diff --git a/crossterm_style/src/winapi_color.rs b/crossterm_style/src/winapi_color.rs index 181393e62..186e839ea 100644 --- a/crossterm_style/src/winapi_color.rs +++ b/crossterm_style/src/winapi_color.rs @@ -2,7 +2,7 @@ //! This module is used for non supporting `ANSI` Windows terminals. use std::io; -use std::sync::{Once, ONCE_INIT}; +use std::sync::Once; use crossterm_utils::Result; use crossterm_winapi::{Console, Handle, HandleType, ScreenBuffer}; @@ -187,5 +187,5 @@ fn original_console_color() -> u16 { return unsafe { ORIGINAL_CONSOLE_COLOR }; } -static GET_ORIGINAL_CONSOLE_COLOR: Once = ONCE_INIT; +static GET_ORIGINAL_CONSOLE_COLOR: Once = Once::new(); static mut ORIGINAL_CONSOLE_COLOR: u16 = 0; diff --git a/crossterm_winapi/src/console.rs b/crossterm_winapi/src/console.rs index 8161aa6ef..8d959245d 100644 --- a/crossterm_winapi/src/console.rs +++ b/crossterm_winapi/src/console.rs @@ -1,8 +1,7 @@ -use super::{is_true, Coord, Handle, HandleType, WindowPositions}; +use std::borrow::ToOwned; use std::io::{self, Error, Result}; use std::str; -use std::borrow::ToOwned; use winapi::ctypes::c_void; use winapi::shared::minwindef::DWORD; use winapi::shared::ntdef::NULL; @@ -17,6 +16,8 @@ use winapi::um::{ use InputRecord; +use super::{is_true, Coord, Handle, HandleType, WindowPositions}; + /// Could be used to do some basic things with the console. pub struct Console { handle: Handle, @@ -165,7 +166,7 @@ impl Console { } pub fn read_single_input_event(&self) -> Result> { - let mut buf_len = self.number_of_console_input_events()?; + let buf_len = self.number_of_console_input_events()?; // Fast-skipping all the code below if there is nothing to read at all if buf_len == 0 { @@ -182,7 +183,7 @@ impl Console { } pub fn read_console_input(&self) -> Result<(u32, Vec)> { - let mut buf_len = self.number_of_console_input_events()?; + let buf_len = self.number_of_console_input_events()?; // Fast-skipping all the code below if there is nothing to read at all if buf_len == 0 {