refactor: m_button, help box text
This commit is contained in:
+30
-35
@@ -74,41 +74,7 @@ impl InputHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Handle any keyboard button events
|
fn m_button(&mut self) {
|
||||||
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') => {
|
|
||||||
if self.mouse_capture {
|
if self.mouse_capture {
|
||||||
match execute!(std::io::stdout(), DisableMouseCapture) {
|
match execute!(std::io::stdout(), DisableMouseCapture) {
|
||||||
Ok(_) => self
|
Ok(_) => self
|
||||||
@@ -142,6 +108,35 @@ impl InputHandler {
|
|||||||
|
|
||||||
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) {
|
||||||
|
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::Tab => self.gui_state.lock().next_panel(),
|
||||||
KeyCode::BackTab => self.gui_state.lock().previous_panel(),
|
KeyCode::BackTab => self.gui_state.lock().previous_panel(),
|
||||||
KeyCode::Home => {
|
KeyCode::Home => {
|
||||||
|
|||||||
@@ -471,12 +471,15 @@ pub fn draw_heading_bar<B: Backend>(
|
|||||||
pub fn draw_help_box<B: Backend>(f: &mut Frame<'_, B>) {
|
pub fn draw_help_box<B: Backend>(f: &mut Frame<'_, B>) {
|
||||||
let title = format!(" {} ", VERSION);
|
let title = format!(" {} ", VERSION);
|
||||||
|
|
||||||
let mut description_text =
|
let mut description_text = String::new();
|
||||||
String::from("\n A basic docker container information viewer and controller.");
|
// 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 ( tab ) or ( alt+tab ) to change panels");
|
||||||
description_text.push_str("\n Mouse input also available.");
|
description_text.push_str("\n ( ↑ ↓ ← → ) mto change selected line");
|
||||||
description_text.push_str("\n ( q ) to quit at any time.");
|
description_text.push_str("\n ( enter ) to send docker container commands");
|
||||||
description_text.push_str("\n ( m ) to toggle mouse capture. When disabled, text on screen can be selected & copied, but mouse clicks get disabled");
|
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
|
description_text
|
||||||
.push_str("\n\n currenty an early work in progress, all and any input appreciated");
|
.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());
|
description_text.push_str(format!("\n {}", REPO.trim()).as_str());
|
||||||
|
|||||||
Reference in New Issue
Block a user