Fix clippy warnings (#551)
This commit is contained in:
parent
a9d9aff3f0
commit
6a8f4fdf94
@ -41,7 +41,7 @@ pub(crate) struct UnixInternalEventSource {
|
|||||||
|
|
||||||
impl UnixInternalEventSource {
|
impl UnixInternalEventSource {
|
||||||
pub fn new() -> Result<Self> {
|
pub fn new() -> Result<Self> {
|
||||||
Ok(UnixInternalEventSource::from_file_descriptor(tty_fd()?)?)
|
UnixInternalEventSource::from_file_descriptor(tty_fd()?)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn from_file_descriptor(input_fd: FileDesc) -> Result<Self> {
|
pub(crate) fn from_file_descriptor(input_fd: FileDesc) -> Result<Self> {
|
||||||
|
@ -23,6 +23,10 @@ impl WindowsEventSource {
|
|||||||
let console = Console::from(Handle::current_in_handle()?);
|
let console = Console::from(Handle::current_in_handle()?);
|
||||||
Ok(WindowsEventSource {
|
Ok(WindowsEventSource {
|
||||||
console,
|
console,
|
||||||
|
|
||||||
|
#[cfg(not(feature = "event-stream"))]
|
||||||
|
poll: WinApiPoll::new(),
|
||||||
|
#[cfg(feature = "event-stream")]
|
||||||
poll: WinApiPoll::new()?,
|
poll: WinApiPoll::new()?,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -37,8 +41,8 @@ impl EventSource for WindowsEventSource {
|
|||||||
let number = self.console.number_of_console_input_events()?;
|
let number = self.console.number_of_console_input_events()?;
|
||||||
if event_ready && number != 0 {
|
if event_ready && number != 0 {
|
||||||
let event = match self.console.read_single_input_event()? {
|
let event = match self.console.read_single_input_event()? {
|
||||||
InputRecord::KeyEvent(record) => handle_key_event(record)?,
|
InputRecord::KeyEvent(record) => handle_key_event(record),
|
||||||
InputRecord::MouseEvent(record) => handle_mouse_event(record)?,
|
InputRecord::MouseEvent(record) => handle_mouse_event(record),
|
||||||
InputRecord::WindowBufferSizeEvent(record) => {
|
InputRecord::WindowBufferSizeEvent(record) => {
|
||||||
Some(Event::Resize(record.size.x as u16, record.size.y as u16))
|
Some(Event::Resize(record.size.x as u16, record.size.y as u16))
|
||||||
}
|
}
|
||||||
|
@ -14,21 +14,22 @@ use crate::{
|
|||||||
Result,
|
Result,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub(crate) fn handle_mouse_event(mouse_event: MouseEvent) -> Result<Option<Event>> {
|
pub(crate) fn handle_mouse_event(mouse_event: MouseEvent) -> Option<Event> {
|
||||||
if let Ok(Some(event)) = parse_mouse_event_record(&mouse_event) {
|
if let Ok(Some(event)) = parse_mouse_event_record(&mouse_event) {
|
||||||
return Ok(Some(Event::Mouse(event)));
|
return Some(Event::Mouse(event));
|
||||||
}
|
}
|
||||||
Ok(None)
|
|
||||||
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn handle_key_event(key_event: KeyEventRecord) -> Result<Option<Event>> {
|
pub(crate) fn handle_key_event(key_event: KeyEventRecord) -> Option<Event> {
|
||||||
if key_event.key_down {
|
if key_event.key_down {
|
||||||
if let Some(event) = parse_key_event_record(&key_event) {
|
if let Some(event) = parse_key_event_record(&key_event) {
|
||||||
return Ok(Some(Event::Key(event)));
|
return Some(Event::Key(event));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(None)
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<ControlKeyState> for KeyModifiers {
|
impl From<ControlKeyState> for KeyModifiers {
|
||||||
|
@ -22,9 +22,14 @@ pub(crate) struct WinApiPoll {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl WinApiPoll {
|
impl WinApiPoll {
|
||||||
|
#[cfg(not(feature = "event-stream"))]
|
||||||
|
pub(crate) fn new() -> WinApiPoll {
|
||||||
|
WinApiPoll {}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "event-stream")]
|
||||||
pub(crate) fn new() -> Result<WinApiPoll> {
|
pub(crate) fn new() -> Result<WinApiPoll> {
|
||||||
Ok(WinApiPoll {
|
Ok(WinApiPoll {
|
||||||
#[cfg(feature = "event-stream")]
|
|
||||||
waker: Waker::new()?,
|
waker: Waker::new()?,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user