CTRL + G (goto directory)

This commit is contained in:
ChristianVisintin
2020-11-27 17:10:00 +01:00
parent 3ddac307c1
commit dc7e7b726e

View File

@@ -432,8 +432,17 @@ impl FileTransferActivity {
'g' | 'G' => { 'g' | 'G' => {
// Goto // Goto
// If ctrl is enabled... // If ctrl is enabled...
if key.modifiers.intersects(KeyModifiers::CONTROL) {
// Show input popup
self.input_mode = InputMode::Popup(PopupType::Input(String::from("Change working directory"), FileTransferActivity::callback_change_directory));
}
}
'm' | 'M' => {
// Make directory
// If ctrl is enabled...
if key.modifiers.intersects(KeyModifiers::CONTROL) { if key.modifiers.intersects(KeyModifiers::CONTROL) {
// TODO: // TODO:
//self.input_mode = InputMode::Popup(PopupType::Input(String::from("Insert directory name")))
} }
} }
'r' | 'R' => { 'r' | 'R' => {
@@ -699,6 +708,22 @@ impl FileTransferActivity {
self.input_mode = InputMode::Explorer; self.input_mode = InputMode::Explorer;
} }
/// ### callback_change_directory
///
/// Callback for GOTO command
fn callback_change_directory(&mut self, context: &mut Context, input: String) {
match context.local.change_wrkdir(PathBuf::from(input.as_str())) {
Err(err) => {
// Report err
self.input_mode = InputMode::Popup(PopupType::Alert(
Color::Red,
format!("Could not change working directory: {}", err),
));
}
Ok(_) => self.local.files = context.local.list_dir() // Update files
}
}
/// ### callback_delete_fsentry /// ### callback_delete_fsentry
/// ///
/// Delete current selected fsentry in the currently selected TAB /// Delete current selected fsentry in the currently selected TAB