From b8b29371ca1fe0b135b7044aca37a5da0b6f58db Mon Sep 17 00:00:00 2001 From: ChristianVisintin Date: Mon, 14 Dec 2020 13:52:49 +0100 Subject: [PATCH] Reload directory content with '' --- CHANGELOG.md | 2 + README.md | 1 + .../activities/filetransfer_activity/input.rs | 31 ++++++++---- .../filetransfer_activity/layout.rs | 50 ++++++++++--------- 4 files changed, 50 insertions(+), 34 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 151512d..67a0d4f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,8 @@ Released on 14/12/2020 - Explorer tabs have now 70% of layout height, while logging area is 30% - Auth page: - align popup text to center +- Keybindings: + - `L`: Refresh directory content - Bugfix: - Fixed memory vulnerability in Windows version diff --git a/README.md b/README.md index 47d360e..ee11952 100644 --- a/README.md +++ b/README.md @@ -198,6 +198,7 @@ Password can be basically provided through 3 ways when address argument is provi | `` | Go to supplied path | | `` | Show help | | `` | Show info about selected file or directory | +| `` | Reload current directory's content | | `` | Quit TermSCP | | `` | Rename file | | `` | Go to parent directory | diff --git a/src/ui/activities/filetransfer_activity/input.rs b/src/ui/activities/filetransfer_activity/input.rs index 6b75537..bcec781 100644 --- a/src/ui/activities/filetransfer_activity/input.rs +++ b/src/ui/activities/filetransfer_activity/input.rs @@ -219,6 +219,11 @@ impl FileTransferActivity { // Show file info self.input_mode = InputMode::Popup(PopupType::FileInfo); } + 'l' | 'L' => { + // Reload file entries + let pwd: PathBuf = self.context.as_ref().unwrap().local.pwd(); + self.local_scan(pwd.as_path()); + } 'r' | 'R' => { // Rename self.input_mode = InputMode::Popup(PopupType::Input( @@ -368,10 +373,6 @@ impl FileTransferActivity { } } KeyCode::Char(ch) => match ch { - 'q' | 'Q' => { - // 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) { @@ -388,6 +389,13 @@ impl FileTransferActivity { )) } } + 'd' | 'D' => { + // Make directory + self.input_mode = InputMode::Popup(PopupType::Input( + String::from("Insert directory name"), + FileTransferActivity::callback_mkdir, + )); + } 'g' | 'G' => { // Goto // Show input popup @@ -396,13 +404,6 @@ impl FileTransferActivity { FileTransferActivity::callback_change_directory, )); } - 'd' | 'D' => { - // Make directory - self.input_mode = InputMode::Popup(PopupType::Input( - String::from("Insert directory name"), - FileTransferActivity::callback_mkdir, - )); - } 'h' | 'H' => { // Show help self.input_mode = InputMode::Popup(PopupType::Help); @@ -411,6 +412,14 @@ impl FileTransferActivity { // Show file info self.input_mode = InputMode::Popup(PopupType::FileInfo); } + 'l' | 'L' => { + // Reload file entries + self.reload_remote_dir(); + } + 'q' | 'Q' => { + // Create quit prompt dialog + self.input_mode = self.create_quit_popup(); + } 'r' | 'R' => { // Rename self.input_mode = InputMode::Popup(PopupType::Input( diff --git a/src/ui/activities/filetransfer_activity/layout.rs b/src/ui/activities/filetransfer_activity/layout.rs index 8130862..6c45a89 100644 --- a/src/ui/activities/filetransfer_activity/layout.rs +++ b/src/ui/activities/filetransfer_activity/layout.rs @@ -334,9 +334,7 @@ impl FileTransferActivity { let message_rows = textwrap::wrap(text.as_str(), width as usize); let mut lines: Vec = Vec::new(); for msg in message_rows.iter() { - lines.push(ListItem::new(Spans::from( - align_text_center(msg, width), - ))); + lines.push(ListItem::new(Spans::from(align_text_center(msg, width)))); } List::new(lines) .block( @@ -357,9 +355,7 @@ impl FileTransferActivity { let message_rows = textwrap::wrap(text.as_str(), width as usize); let mut lines: Vec = Vec::new(); for msg in message_rows.iter() { - lines.push(ListItem::new(Spans::from( - align_text_center(msg, width), - ))); + lines.push(ListItem::new(Spans::from(align_text_center(msg, width)))); } List::new(lines) .block( @@ -415,9 +411,7 @@ impl FileTransferActivity { let message_rows = textwrap::wrap(text.as_str(), width as usize); let mut lines: Vec = Vec::new(); for msg in message_rows.iter() { - lines.push(ListItem::new(Spans::from( - align_text_center(msg, width), - ))); + lines.push(ListItem::new(Spans::from(align_text_center(msg, width)))); } List::new(lines) .block( @@ -624,7 +618,7 @@ impl FileTransferActivity { .add_modifier(Modifier::BOLD), ), Span::raw(" "), - Span::raw("disconnect"), + Span::raw("Disconnect"), ])), ListItem::new(Spans::from(vec![ Span::styled( @@ -654,7 +648,7 @@ impl FileTransferActivity { .add_modifier(Modifier::BOLD), ), Span::raw(" "), - Span::raw("change explorer tab"), + Span::raw("Change explorer tab"), ])), ListItem::new(Spans::from(vec![ Span::styled( @@ -664,7 +658,7 @@ impl FileTransferActivity { .add_modifier(Modifier::BOLD), ), Span::raw(" "), - Span::raw("move up/down in list"), + Span::raw("Move up/down in list"), ])), ListItem::new(Spans::from(vec![ Span::styled( @@ -674,7 +668,7 @@ impl FileTransferActivity { .add_modifier(Modifier::BOLD), ), Span::raw(" "), - Span::raw("scroll up/down in list quickly"), + Span::raw("Scroll up/down in list quickly"), ])), ListItem::new(Spans::from(vec![ Span::styled( @@ -684,7 +678,7 @@ impl FileTransferActivity { .add_modifier(Modifier::BOLD), ), Span::raw(" "), - Span::raw("enter directory"), + Span::raw("Enter directory"), ])), ListItem::new(Spans::from(vec![ Span::styled( @@ -694,7 +688,7 @@ impl FileTransferActivity { .add_modifier(Modifier::BOLD), ), Span::raw(" "), - Span::raw("upload/download file"), + Span::raw("Upload/download file"), ])), ListItem::new(Spans::from(vec![ Span::styled( @@ -704,7 +698,7 @@ impl FileTransferActivity { .add_modifier(Modifier::BOLD), ), Span::raw(" "), - Span::raw("delete file"), + Span::raw("Delete file"), ])), ListItem::new(Spans::from(vec![ Span::styled( @@ -714,7 +708,7 @@ impl FileTransferActivity { .add_modifier(Modifier::BOLD), ), Span::raw(" "), - Span::raw("make directory"), + Span::raw("Make directory"), ])), ListItem::new(Spans::from(vec![ Span::styled( @@ -724,7 +718,7 @@ impl FileTransferActivity { .add_modifier(Modifier::BOLD), ), Span::raw(" "), - Span::raw("goto path"), + Span::raw("Goto path"), ])), ListItem::new(Spans::from(vec![ Span::styled( @@ -734,7 +728,7 @@ impl FileTransferActivity { .add_modifier(Modifier::BOLD), ), Span::raw(" "), - Span::raw("show help"), + Span::raw("Show help"), ])), ListItem::new(Spans::from(vec![ Span::styled( @@ -744,7 +738,17 @@ impl FileTransferActivity { .add_modifier(Modifier::BOLD), ), Span::raw(" "), - Span::raw("show info about the selected file or directory"), + Span::raw("Show info about the selected file or directory"), + ])), + ListItem::new(Spans::from(vec![ + Span::styled( + "", + Style::default() + .fg(Color::Cyan) + .add_modifier(Modifier::BOLD), + ), + Span::raw(" "), + Span::raw("Reload directory content"), ])), ListItem::new(Spans::from(vec![ Span::styled( @@ -764,7 +768,7 @@ impl FileTransferActivity { .add_modifier(Modifier::BOLD), ), Span::raw(" "), - Span::raw("rename file"), + Span::raw("Rename file"), ])), ListItem::new(Spans::from(vec![ Span::styled( @@ -774,7 +778,7 @@ impl FileTransferActivity { .add_modifier(Modifier::BOLD), ), Span::raw(" "), - Span::raw("go to parent directory"), + Span::raw("Go to parent directory"), ])), ListItem::new(Spans::from(vec![ Span::styled( @@ -784,7 +788,7 @@ impl FileTransferActivity { .add_modifier(Modifier::BOLD), ), Span::raw(" "), - Span::raw("abort current file transfer"), + Span::raw("Abort current file transfer"), ])), ]; List::new(cmds)