Ctrl+Q quit; <esc> just disconnect
This commit is contained in:
parent
1f4998b1c1
commit
28a4bed8fa
|
@ -19,7 +19,10 @@
|
|||
*
|
||||
*/
|
||||
|
||||
use super::{DialogCallback, DialogYesNoOption, FileExplorerTab, FileTransferActivity, FsEntry, InputEvent, InputField, InputMode, LogLevel, OnInputSubmitCallback, PopupType};
|
||||
use super::{
|
||||
DialogCallback, DialogYesNoOption, FileExplorerTab, FileTransferActivity, FsEntry, InputEvent,
|
||||
InputField, InputMode, LogLevel, OnInputSubmitCallback, PopupType,
|
||||
};
|
||||
|
||||
use crossterm::event::{KeyCode, KeyModifiers};
|
||||
use std::path::PathBuf;
|
||||
|
@ -72,7 +75,7 @@ impl FileTransferActivity {
|
|||
KeyCode::Esc => {
|
||||
// Handle quit event
|
||||
// Create quit prompt dialog
|
||||
self.input_mode = self.create_quit_popup();
|
||||
self.input_mode = self.create_disconnect_popup();
|
||||
}
|
||||
KeyCode::Tab => self.switch_input_field(), // <TAB> switch tab
|
||||
KeyCode::Right => self.tab = FileExplorerTab::Remote, // <RIGHT> switch to right tab
|
||||
|
@ -172,6 +175,12 @@ impl FileTransferActivity {
|
|||
}
|
||||
}
|
||||
KeyCode::Char(ch) => match ch {
|
||||
'q' | 'Q' => {
|
||||
if key.modifiers.intersects(KeyModifiers::CONTROL) {
|
||||
// Create quit prompt dialog
|
||||
self.input_mode = self.create_quit_popup();
|
||||
}
|
||||
}
|
||||
'g' | 'G' => {
|
||||
// Goto
|
||||
// If ctrl is enabled...
|
||||
|
@ -273,7 +282,7 @@ impl FileTransferActivity {
|
|||
KeyCode::Esc => {
|
||||
// Handle quit event
|
||||
// Create quit prompt dialog
|
||||
self.input_mode = self.create_quit_popup();
|
||||
self.input_mode = self.create_disconnect_popup();
|
||||
}
|
||||
KeyCode::Tab => self.switch_input_field(), // <TAB> switch tab
|
||||
KeyCode::Left => self.tab = FileExplorerTab::Local, // <LEFT> switch to local tab
|
||||
|
@ -367,6 +376,12 @@ impl FileTransferActivity {
|
|||
}
|
||||
}
|
||||
KeyCode::Char(ch) => match ch {
|
||||
'q' | 'Q' => {
|
||||
if key.modifiers.intersects(KeyModifiers::CONTROL) {
|
||||
// Create quit prompt dialog
|
||||
self.input_mode = self.create_quit_popup();
|
||||
}
|
||||
}
|
||||
'g' | 'G' => {
|
||||
// Goto
|
||||
// If ctrl is enabled...
|
||||
|
@ -470,7 +485,7 @@ impl FileTransferActivity {
|
|||
KeyCode::Esc => {
|
||||
// Handle quit event
|
||||
// Create quit prompt dialog
|
||||
self.input_mode = self.create_quit_popup();
|
||||
self.input_mode = self.create_disconnect_popup();
|
||||
}
|
||||
KeyCode::Tab => self.switch_input_field(), // <TAB> switch tab
|
||||
KeyCode::Down => {
|
||||
|
@ -506,6 +521,15 @@ impl FileTransferActivity {
|
|||
self.log_index = self.log_index + records_block; // Increase by `records_block`
|
||||
}
|
||||
}
|
||||
KeyCode::Char(ch) => match ch {
|
||||
'q' | 'Q' => {
|
||||
if key.modifiers.intersects(KeyModifiers::CONTROL) {
|
||||
// Create quit prompt dialog
|
||||
self.input_mode = self.create_quit_popup();
|
||||
}
|
||||
}
|
||||
_ => { /* Nothing to do */ }
|
||||
},
|
||||
_ => { /* Nothing to do */ }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -387,7 +387,7 @@ impl FileTransferActivity {
|
|||
.add_modifier(Modifier::BOLD),
|
||||
),
|
||||
Span::raw(" "),
|
||||
Span::raw("quit"),
|
||||
Span::raw("disconnect"),
|
||||
])),
|
||||
ListItem::new(Spans::from(vec![
|
||||
Span::styled(
|
||||
|
@ -477,6 +477,17 @@ impl FileTransferActivity {
|
|||
Span::raw(" "),
|
||||
Span::raw("goto path"),
|
||||
])),
|
||||
ListItem::new(Spans::from(vec![
|
||||
Span::styled(
|
||||
"<CTRL+Q>",
|
||||
Style::default()
|
||||
.bg(Color::Cyan)
|
||||
.fg(Color::White)
|
||||
.add_modifier(Modifier::BOLD),
|
||||
),
|
||||
Span::raw(" "),
|
||||
Span::raw("Quit TermSCP"),
|
||||
])),
|
||||
ListItem::new(Spans::from(vec![
|
||||
Span::styled(
|
||||
"<CTRL+R>",
|
||||
|
|
|
@ -38,13 +38,24 @@ impl FileTransferActivity {
|
|||
self.log_index = 0;
|
||||
}
|
||||
|
||||
/// ### create_quit_popup
|
||||
///
|
||||
/// Create quit popup input mode (since must be shared between different input handlers)
|
||||
pub(super) fn create_disconnect_popup(&mut self) -> InputMode {
|
||||
InputMode::Popup(PopupType::YesNo(
|
||||
String::from("Are you sure you want to disconnect?"),
|
||||
FileTransferActivity::disconnect,
|
||||
FileTransferActivity::callback_nothing_to_do,
|
||||
))
|
||||
}
|
||||
|
||||
/// ### create_quit_popup
|
||||
///
|
||||
/// Create quit popup input mode (since must be shared between different input handlers)
|
||||
pub(super) fn create_quit_popup(&mut self) -> InputMode {
|
||||
InputMode::Popup(PopupType::YesNo(
|
||||
String::from("Are you sure you want to quit?"),
|
||||
FileTransferActivity::disconnect,
|
||||
FileTransferActivity::disconnect_and_quit,
|
||||
FileTransferActivity::callback_nothing_to_do,
|
||||
))
|
||||
}
|
||||
|
|
|
@ -76,6 +76,14 @@ impl FileTransferActivity {
|
|||
self.disconnected = true;
|
||||
}
|
||||
|
||||
/// ### disconnect_and_quit
|
||||
///
|
||||
/// disconnect from remote and then quit
|
||||
pub(super) fn disconnect_and_quit(&mut self) {
|
||||
self.disconnect();
|
||||
self.quit = true;
|
||||
}
|
||||
|
||||
/// ### reload_remote_dir
|
||||
///
|
||||
/// Reload remote directory entries
|
||||
|
|
Loading…
Reference in a new issue