Go to parent directory with <BACKSPACE>

This commit is contained in:
ChristianVisintin
2020-11-27 17:01:52 +01:00
parent 58911117bd
commit 3ddac307c1

View File

@@ -381,11 +381,9 @@ impl FileTransferActivity {
KeyCode::Enter => { KeyCode::Enter => {
// Match selected file // Match selected file
if let Some(entry) = self.local.files.get(self.local.index) { if let Some(entry) = self.local.files.get(self.local.index) {
match entry { if let FsEntry::Directory(dir) = entry {
FsEntry::Directory(dir) => {
// Change directory // Change directory
if let Err(err) = if let Err(err) = context.local.change_wrkdir(dir.abs_path.clone())
context.local.change_wrkdir(dir.abs_path.clone())
{ {
// Report err // Report err
self.input_mode = InputMode::Popup(PopupType::Alert( self.input_mode = InputMode::Popup(PopupType::Alert(
@@ -396,10 +394,22 @@ impl FileTransferActivity {
// Update files // Update files
self.local.files = context.local.list_dir(); self.local.files = context.local.list_dir();
} }
FsEntry::File(file) => {
// TODO: upload file
} }
} }
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 => { KeyCode::Delete => {
@@ -433,6 +443,9 @@ impl FileTransferActivity {
// TODO: // TODO:
} }
} }
' ' => {
// TODO: Upload file
}
_ => { /* Nothing to do */ } _ => { /* Nothing to do */ }
}, },
_ => { /* Nothing to do */ } _ => { /* Nothing to do */ }