refactor: help box description from TOML
This commit is contained in:
+32
-32
@@ -74,40 +74,40 @@ impl InputHandler {
|
||||
}
|
||||
}
|
||||
|
||||
fn m_button(&mut self) {
|
||||
if self.mouse_capture {
|
||||
match execute!(std::io::stdout(), DisableMouseCapture) {
|
||||
Ok(_) => self
|
||||
.gui_state
|
||||
.lock()
|
||||
.set_info_box("✖ mouse capture disabled".to_owned()),
|
||||
Err(_) => self
|
||||
.app_data
|
||||
.lock()
|
||||
.set_error(AppError::MouseCapture(false)),
|
||||
}
|
||||
} else {
|
||||
match execute!(std::io::stdout(), EnableMouseCapture) {
|
||||
Ok(_) => self
|
||||
.gui_state
|
||||
.lock()
|
||||
.set_info_box("✓ mouse capture enabled".to_owned()),
|
||||
Err(_) => self.app_data.lock().set_error(AppError::MouseCapture(true)),
|
||||
}
|
||||
};
|
||||
fn m_button(&mut self) {
|
||||
if self.mouse_capture {
|
||||
match execute!(std::io::stdout(), DisableMouseCapture) {
|
||||
Ok(_) => self
|
||||
.gui_state
|
||||
.lock()
|
||||
.set_info_box("✖ mouse capture disabled".to_owned()),
|
||||
Err(_) => self
|
||||
.app_data
|
||||
.lock()
|
||||
.set_error(AppError::MouseCapture(false)),
|
||||
}
|
||||
} else {
|
||||
match execute!(std::io::stdout(), EnableMouseCapture) {
|
||||
Ok(_) => self
|
||||
.gui_state
|
||||
.lock()
|
||||
.set_info_box("✓ mouse capture enabled".to_owned()),
|
||||
Err(_) => self.app_data.lock().set_error(AppError::MouseCapture(true)),
|
||||
}
|
||||
};
|
||||
|
||||
let gui_state = Arc::clone(&self.gui_state);
|
||||
let gui_state = Arc::clone(&self.gui_state);
|
||||
|
||||
if self.info_sleep.is_some() {
|
||||
self.info_sleep.as_ref().unwrap().abort()
|
||||
}
|
||||
self.info_sleep = Some(tokio::spawn(async move {
|
||||
tokio::time::sleep(std::time::Duration::from_millis(4000)).await;
|
||||
gui_state.lock().reset_info_box()
|
||||
}));
|
||||
if self.info_sleep.is_some() {
|
||||
self.info_sleep.as_ref().unwrap().abort()
|
||||
}
|
||||
self.info_sleep = Some(tokio::spawn(async move {
|
||||
tokio::time::sleep(std::time::Duration::from_millis(4000)).await;
|
||||
gui_state.lock().reset_info_box()
|
||||
}));
|
||||
|
||||
self.mouse_capture = !self.mouse_capture;
|
||||
}
|
||||
self.mouse_capture = !self.mouse_capture;
|
||||
}
|
||||
|
||||
/// Handle any keyboard button events
|
||||
async fn button_press(&mut self, key_code: KeyCode) {
|
||||
@@ -129,7 +129,7 @@ impl InputHandler {
|
||||
match key_code {
|
||||
KeyCode::Char('q') => self.is_running.store(false, Ordering::SeqCst),
|
||||
KeyCode::Char('h') => self.gui_state.lock().show_help = false,
|
||||
KeyCode::Char('m') => self.m_button(),
|
||||
KeyCode::Char('m') => self.m_button(),
|
||||
_ => (),
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user