From 3ddac307c1df351ad2ab4659e253a9eab54f2b2b Mon Sep 17 00:00:00 2001 From: ChristianVisintin Date: Fri, 27 Nov 2020 17:01:52 +0100 Subject: [PATCH] Go to parent directory with --- src/ui/activities/filetransfer_activity.rs | 47 ++++++++++++++-------- 1 file changed, 30 insertions(+), 17 deletions(-) diff --git a/src/ui/activities/filetransfer_activity.rs b/src/ui/activities/filetransfer_activity.rs index 0b68600..91d964e 100644 --- a/src/ui/activities/filetransfer_activity.rs +++ b/src/ui/activities/filetransfer_activity.rs @@ -381,27 +381,37 @@ impl FileTransferActivity { KeyCode::Enter => { // Match selected file if let Some(entry) = self.local.files.get(self.local.index) { - match entry { - FsEntry::Directory(dir) => { - // Change directory - if let Err(err) = - context.local.change_wrkdir(dir.abs_path.clone()) - { - // Report err - self.input_mode = InputMode::Popup(PopupType::Alert( - Color::Red, - format!("Could not change working directory: {}", err), - )); - } - // Update files - self.local.files = context.local.list_dir(); - } - FsEntry::File(file) => { - // TODO: upload file + if let FsEntry::Directory(dir) = entry { + // Change directory + if let Err(err) = context.local.change_wrkdir(dir.abs_path.clone()) + { + // Report err + self.input_mode = InputMode::Popup(PopupType::Alert( + Color::Red, + format!("Could not change working directory: {}", err), + )); } + // Update files + self.local.files = context.local.list_dir(); } } } + KeyCode::Backspace => { + // Go previous directory + let wrkdir: PathBuf = context.local.pwd(); + if let Some(parent) = wrkdir.as_path().parent() { + // Change directory + if let Err(err) = context.local.change_wrkdir(PathBuf::from(parent)) { + // Report err + self.input_mode = InputMode::Popup(PopupType::Alert( + Color::Red, + format!("Could not change working directory: {}", err), + )); + } + // Update files + self.local.files = context.local.list_dir(); + } + } KeyCode::Delete => { // Get file at index if let Some(entry) = self.local.files.get(self.local.index) { @@ -433,6 +443,9 @@ impl FileTransferActivity { // TODO: } } + ' ' => { + // TODO: Upload file + } _ => { /* Nothing to do */ } }, _ => { /* Nothing to do */ }