better structure
This commit is contained in:
@@ -9,13 +9,13 @@ use crate::{
|
||||
};
|
||||
|
||||
impl Event for KeyEvent {
|
||||
fn as_any(self: Box<Self>) -> Box<dyn std::any::Any> {
|
||||
fn as_any(&self) -> &dyn std::any::Any {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
pub trait KeyPressEventHandler {
|
||||
fn on_keypress(&mut self, events: &Arc<EventManager>, event: Box<KeyEvent>);
|
||||
fn on_keypress(&mut self, events: &Arc<EventManager>, event: &KeyEvent);
|
||||
}
|
||||
|
||||
pub struct KeyPressExtension;
|
||||
@@ -26,7 +26,7 @@ impl Extension for KeyPressExtension {
|
||||
crate::utils::clear().unwrap();
|
||||
crate::utils::hide_cursor().unwrap();
|
||||
|
||||
events.on(|_, _: Box<Close>| {
|
||||
events.on(|_, _: &Close| {
|
||||
crossterm::terminal::disable_raw_mode().unwrap();
|
||||
crate::utils::show_cursor().unwrap();
|
||||
crate::utils::clear().unwrap();
|
||||
|
||||
Reference in New Issue
Block a user