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,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 */ }