From 1fb614642c0c899d39abc0cb9a8134a361ef13c5 Mon Sep 17 00:00:00 2001 From: ChristianVisintin Date: Sat, 12 Dec 2020 17:44:04 +0100 Subject: [PATCH] Added 'E' to keybindings; behaves as (added because some keyboards don't have --- CHANGELOG.md | 2 + README.md | 5 ++- .../activities/filetransfer_activity/input.rs | 38 ++++++++++++++++++- .../filetransfer_activity/layout.rs | 4 +- 4 files changed, 44 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e8cc67..7e5e92a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,8 @@ Released on ?? - General performance and code improvements - Improved symlinks management +- Keybindings: + - `E`: Delete file (Same as `DEL`); added because some keyboards don't have `DEL` (hey, that's my MacBook Air's keyboard!) ## 0.1.1 diff --git a/README.md b/README.md index ace84ba..d2c9490 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ Current version: 0.1.1 (10/12/2020) - [Documentation ๐Ÿ“š](#documentation-) - [Known issues ๐Ÿงป](#known-issues-) - [Upcoming Features ๐Ÿงช](#upcoming-features-) - - [Contributions ๏ฟฝ๐Ÿป](#contributions-) + - [Contributions ๐Ÿค๐Ÿป](#contributions-) - [Changelog โณ](#changelog-) - [Powered by ๐Ÿš€](#powered-by-) - [Gallery ๐ŸŽฌ](#gallery-) @@ -194,13 +194,14 @@ Password can be basically provided through 3 ways when address argument is provi | `` | Enter directory | | `` | Upload / download selected file | | `` | Make directory | +| `` | Delete file (Same as `CANC`) | | `` | Go to supplied path | | `` | Show help | | `` | Show info about selected file or directory | | `` | Quit TermSCP | | `` | Rename file | | `` | Go to parent directory | -| `` | Delete file | +| `` | Delete file | --- diff --git a/src/ui/activities/filetransfer_activity/input.rs b/src/ui/activities/filetransfer_activity/input.rs index 791233f..7d64bfc 100644 --- a/src/ui/activities/filetransfer_activity/input.rs +++ b/src/ui/activities/filetransfer_activity/input.rs @@ -155,6 +155,22 @@ impl FileTransferActivity { // Create quit prompt dialog self.input_mode = self.create_quit_popup(); } + 'e' | 'E' => { + // Get file at index + if let Some(entry) = self.local.files.get(self.local.index) { + // Get file name + let file_name: String = match entry { + FsEntry::Directory(dir) => dir.name.clone(), + FsEntry::File(file) => file.name.clone(), + }; + // Show delete prompt + self.input_mode = InputMode::Popup(PopupType::YesNo( + format!("Delete file \"{}\"", file_name), + FileTransferActivity::callback_delete_fsentry, + FileTransferActivity::callback_nothing_to_do, + )) + } + } 'g' | 'G' => { // Goto // Show input popup @@ -223,7 +239,11 @@ impl FileTransferActivity { if let Some(entry) = files.get(self.local.index) { let name: String = entry.get_name(); // Call upload; pass realfile, keep link name - self.filetransfer_send(&entry.get_realfile(), wrkdir.as_path(), Some(name)); + self.filetransfer_send( + &entry.get_realfile(), + wrkdir.as_path(), + Some(name), + ); } } _ => { /* Nothing to do */ } @@ -324,6 +344,22 @@ impl FileTransferActivity { // Create quit prompt dialog self.input_mode = self.create_quit_popup(); } + 'e' | 'E' => { + // Get file at index + if let Some(entry) = self.remote.files.get(self.remote.index) { + // Get file name + let file_name: String = match entry { + FsEntry::Directory(dir) => dir.name.clone(), + FsEntry::File(file) => file.name.clone(), + }; + // Show delete prompt + self.input_mode = InputMode::Popup(PopupType::YesNo( + format!("Delete file \"{}\"", file_name), + FileTransferActivity::callback_delete_fsentry, + FileTransferActivity::callback_nothing_to_do, + )) + } + } 'g' | 'G' => { // Goto // Show input popup diff --git a/src/ui/activities/filetransfer_activity/layout.rs b/src/ui/activities/filetransfer_activity/layout.rs index f5223fc..95c9501 100644 --- a/src/ui/activities/filetransfer_activity/layout.rs +++ b/src/ui/activities/filetransfer_activity/layout.rs @@ -692,12 +692,12 @@ impl FileTransferActivity { ])), ListItem::new(Spans::from(vec![ Span::styled( - "", + "", Style::default() .fg(Color::Cyan) .add_modifier(Modifier::BOLD), ), - Span::raw(" "), + Span::raw(" "), Span::raw("delete file"), ])), ListItem::new(Spans::from(vec![