refactor: m_button, help box text

This commit is contained in:
Jack Wills
2022-04-29 01:30:31 +00:00
parent 12b5cfce6c
commit 00dfacfe13
2 changed files with 50 additions and 52 deletions
+30 -35
View File
@@ -74,41 +74,7 @@ impl InputHandler {
}
}
/// Handle any keyboard button events
async fn button_press(&mut self, key_code: KeyCode) {
let show_error = self.app_data.lock().show_error;
let show_info = self.gui_state.lock().show_help;
if show_error {
match key_code {
KeyCode::Char('q') => {
self.is_running.store(false, Ordering::SeqCst);
}
KeyCode::Char('c') => {
self.app_data.lock().show_error = false;
self.app_data.lock().remove_error();
}
_ => (),
}
} else if show_info {
match key_code {
KeyCode::Char('q') => {
self.is_running.store(false, Ordering::SeqCst);
}
KeyCode::Char('h') => {
self.gui_state.lock().show_help = false;
}
_ => (),
}
} else {
match key_code {
KeyCode::Char('q') => {
self.is_running.store(false, Ordering::SeqCst);
}
KeyCode::Char('h') => {
self.gui_state.lock().show_help = true;
}
KeyCode::Char('m') => {
fn m_button(&mut self) {
if self.mouse_capture {
match execute!(std::io::stdout(), DisableMouseCapture) {
Ok(_) => self
@@ -142,6 +108,35 @@ impl InputHandler {
self.mouse_capture = !self.mouse_capture;
}
/// Handle any keyboard button events
async fn button_press(&mut self, key_code: KeyCode) {
let show_error = self.app_data.lock().show_error;
let show_info = self.gui_state.lock().show_help;
if show_error {
match key_code {
KeyCode::Char('q') => {
self.is_running.store(false, Ordering::SeqCst);
}
KeyCode::Char('c') => {
self.app_data.lock().show_error = false;
self.app_data.lock().remove_error();
}
_ => (),
}
} else if show_info {
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(),
_ => (),
}
} else {
match key_code {
KeyCode::Char('q') => self.is_running.store(false, Ordering::SeqCst),
KeyCode::Char('h') => self.gui_state.lock().show_help = true,
KeyCode::Char('m') => self.m_button(),
KeyCode::Tab => self.gui_state.lock().next_panel(),
KeyCode::BackTab => self.gui_state.lock().previous_panel(),
KeyCode::Home => {
+9 -6
View File
@@ -471,12 +471,15 @@ pub fn draw_heading_bar<B: Backend>(
pub fn draw_help_box<B: Backend>(f: &mut Frame<'_, B>) {
let title = format!(" {} ", VERSION);
let mut description_text =
String::from("\n A basic docker container information viewer and controller.");
description_text.push_str("\n Tab or Alt+Tab to change panels, arrows to change lines, enter to send docker container commands.");
description_text.push_str("\n Mouse input also available.");
description_text.push_str("\n ( q ) to quit at any time.");
description_text.push_str("\n ( m ) to toggle mouse capture. When disabled, text on screen can be selected & copied, but mouse clicks get disabled");
let mut description_text = String::new();
// String::from("\n A basic docker container information viewer and controller.");
description_text.push_str("\n ( tab ) or ( alt+tab ) to change panels");
description_text.push_str("\n ( ↑ ↓ ← → ) mto change selected line");
description_text.push_str("\n ( enter ) to send docker container commands");
description_text.push_str("\n ( m ) to toggle mouse capture - if disabled, text on screen can be selected & copied, but mouse clicks get disabled");
description_text.push_str("\n ( h ) to toggle this help information");
description_text.push_str("\n ( q ) to quit at any time");
description_text.push_str("\n mouse scrolling & clicking also available");
description_text
.push_str("\n\n currenty an early work in progress, all and any input appreciated");
description_text.push_str(format!("\n {}", REPO.trim()).as_str());