mirror of
https://github.com/veeso/termscp.git
synced 2025-12-07 09:36:00 -08:00
It is now possible to keep navigating on the other explorer while 'found tab' is open
This commit is contained in:
committed by
Christian Visintin
parent
cb583f305c
commit
26ff496829
@@ -32,6 +32,8 @@ Released on FIXME:
|
|||||||
- Find feature:
|
- Find feature:
|
||||||
- A "wait popup" will now be displayed while searching files
|
- A "wait popup" will now be displayed while searching files
|
||||||
- If find command doesn't return any result show an info dialog and not an empty explorer
|
- If find command doesn't return any result show an info dialog and not an empty explorer
|
||||||
|
- It is now possible to keep navigating on the other explorer while "found tab" is open
|
||||||
|
- ❗ It is not possible though to have the "found tab" on both explorers (otherwise you wouldn't be able to tell whether you're transferring files)
|
||||||
|
|
||||||
## 0.7.0
|
## 0.7.0
|
||||||
|
|
||||||
|
|||||||
@@ -40,14 +40,23 @@ pub enum FileExplorerTab {
|
|||||||
FindRemote, // Find result tab
|
FindRemote, // Find result tab
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// ## FoundExplorerTab
|
||||||
|
///
|
||||||
|
/// Describes the explorer tab type
|
||||||
|
#[derive(Copy, Clone, Debug)]
|
||||||
|
pub enum FoundExplorerTab {
|
||||||
|
Local,
|
||||||
|
Remote,
|
||||||
|
}
|
||||||
|
|
||||||
/// ## Browser
|
/// ## Browser
|
||||||
///
|
///
|
||||||
/// Browser contains the browser options
|
/// Browser contains the browser options
|
||||||
pub struct Browser {
|
pub struct Browser {
|
||||||
local: FileExplorer, // Local File explorer state
|
local: FileExplorer, // Local File explorer state
|
||||||
remote: FileExplorer, // Remote File explorer state
|
remote: FileExplorer, // Remote File explorer state
|
||||||
found: Option<FileExplorer>, // File explorer for find result
|
found: Option<(FoundExplorerTab, FileExplorer)>, // File explorer for find result
|
||||||
tab: FileExplorerTab, // Current selected tab
|
tab: FileExplorerTab, // Current selected tab
|
||||||
pub sync_browsing: bool,
|
pub sync_browsing: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,23 +91,30 @@ impl Browser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn found(&self) -> Option<&FileExplorer> {
|
pub fn found(&self) -> Option<&FileExplorer> {
|
||||||
self.found.as_ref()
|
self.found.as_ref().map(|x| &x.1)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn found_mut(&mut self) -> Option<&mut FileExplorer> {
|
pub fn found_mut(&mut self) -> Option<&mut FileExplorer> {
|
||||||
self.found.as_mut()
|
self.found.as_mut().map(|x| &mut x.1)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_found(&mut self, files: Vec<FsEntry>) {
|
pub fn set_found(&mut self, tab: FoundExplorerTab, files: Vec<FsEntry>) {
|
||||||
let mut explorer = Self::build_found_explorer();
|
let mut explorer = Self::build_found_explorer();
|
||||||
explorer.set_files(files);
|
explorer.set_files(files);
|
||||||
self.found = Some(explorer);
|
self.found = Some((tab, explorer));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn del_found(&mut self) {
|
pub fn del_found(&mut self) {
|
||||||
self.found = None;
|
self.found = None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// ### found_tab
|
||||||
|
///
|
||||||
|
/// Returns found tab if any
|
||||||
|
pub fn found_tab(&self) -> Option<FoundExplorerTab> {
|
||||||
|
self.found.as_ref().map(|x| x.0)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn tab(&self) -> FileExplorerTab {
|
pub fn tab(&self) -> FileExplorerTab {
|
||||||
self.tab
|
self.tab
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,15 +27,17 @@
|
|||||||
*/
|
*/
|
||||||
// locals
|
// locals
|
||||||
use super::{
|
use super::{
|
||||||
actions::SelectedEntry, browser::FileExplorerTab, FileTransferActivity, LogLevel, TransferOpts,
|
actions::SelectedEntry,
|
||||||
COMPONENT_EXPLORER_FIND, COMPONENT_EXPLORER_LOCAL, COMPONENT_EXPLORER_REMOTE,
|
browser::{FileExplorerTab, FoundExplorerTab},
|
||||||
COMPONENT_INPUT_COPY, COMPONENT_INPUT_EXEC, COMPONENT_INPUT_FIND, COMPONENT_INPUT_GOTO,
|
FileTransferActivity, LogLevel, TransferOpts, COMPONENT_EXPLORER_FIND,
|
||||||
COMPONENT_INPUT_MKDIR, COMPONENT_INPUT_NEWFILE, COMPONENT_INPUT_OPEN_WITH,
|
COMPONENT_EXPLORER_LOCAL, COMPONENT_EXPLORER_REMOTE, COMPONENT_INPUT_COPY,
|
||||||
COMPONENT_INPUT_RENAME, COMPONENT_INPUT_SAVEAS, COMPONENT_LIST_FILEINFO,
|
COMPONENT_INPUT_EXEC, COMPONENT_INPUT_FIND, COMPONENT_INPUT_GOTO, COMPONENT_INPUT_MKDIR,
|
||||||
COMPONENT_LIST_REPLACING_FILES, COMPONENT_LOG_BOX, COMPONENT_PROGRESS_BAR_FULL,
|
COMPONENT_INPUT_NEWFILE, COMPONENT_INPUT_OPEN_WITH, COMPONENT_INPUT_RENAME,
|
||||||
COMPONENT_PROGRESS_BAR_PARTIAL, COMPONENT_RADIO_DELETE, COMPONENT_RADIO_DISCONNECT,
|
COMPONENT_INPUT_SAVEAS, COMPONENT_LIST_FILEINFO, COMPONENT_LIST_REPLACING_FILES,
|
||||||
COMPONENT_RADIO_QUIT, COMPONENT_RADIO_REPLACE, COMPONENT_RADIO_SORTING, COMPONENT_TEXT_ERROR,
|
COMPONENT_LOG_BOX, COMPONENT_PROGRESS_BAR_FULL, COMPONENT_PROGRESS_BAR_PARTIAL,
|
||||||
COMPONENT_TEXT_FATAL, COMPONENT_TEXT_HELP,
|
COMPONENT_RADIO_DELETE, COMPONENT_RADIO_DISCONNECT, COMPONENT_RADIO_QUIT,
|
||||||
|
COMPONENT_RADIO_REPLACE, COMPONENT_RADIO_SORTING, COMPONENT_TEXT_ERROR, COMPONENT_TEXT_FATAL,
|
||||||
|
COMPONENT_TEXT_HELP,
|
||||||
};
|
};
|
||||||
use crate::fs::explorer::FileSorting;
|
use crate::fs::explorer::FileSorting;
|
||||||
use crate::fs::FsEntry;
|
use crate::fs::FsEntry;
|
||||||
@@ -64,6 +66,15 @@ impl Update for FileTransferActivity {
|
|||||||
None => None, // Exit after None
|
None => None, // Exit after None
|
||||||
Some(msg) => match msg {
|
Some(msg) => match msg {
|
||||||
// -- local tab
|
// -- local tab
|
||||||
|
(COMPONENT_EXPLORER_LOCAL, key)
|
||||||
|
if key == &MSG_KEY_RIGHT
|
||||||
|
&& matches!(self.browser.found_tab(), Some(FoundExplorerTab::Remote)) =>
|
||||||
|
{
|
||||||
|
// Go to find explorer
|
||||||
|
self.view.active(COMPONENT_EXPLORER_FIND);
|
||||||
|
self.browser.change_tab(FileExplorerTab::FindRemote);
|
||||||
|
None
|
||||||
|
}
|
||||||
(COMPONENT_EXPLORER_LOCAL, key) if key == &MSG_KEY_RIGHT => {
|
(COMPONENT_EXPLORER_LOCAL, key) if key == &MSG_KEY_RIGHT => {
|
||||||
// Change tab
|
// Change tab
|
||||||
self.view.active(COMPONENT_EXPLORER_REMOTE);
|
self.view.active(COMPONENT_EXPLORER_REMOTE);
|
||||||
@@ -137,6 +148,15 @@ impl Update for FileTransferActivity {
|
|||||||
self.update_local_filelist()
|
self.update_local_filelist()
|
||||||
}
|
}
|
||||||
// -- remote tab
|
// -- remote tab
|
||||||
|
(COMPONENT_EXPLORER_REMOTE, key)
|
||||||
|
if key == &MSG_KEY_LEFT
|
||||||
|
&& matches!(self.browser.found_tab(), Some(FoundExplorerTab::Local)) =>
|
||||||
|
{
|
||||||
|
// Go to find explorer
|
||||||
|
self.view.active(COMPONENT_EXPLORER_FIND);
|
||||||
|
self.browser.change_tab(FileExplorerTab::FindLocal);
|
||||||
|
None
|
||||||
|
}
|
||||||
(COMPONENT_EXPLORER_REMOTE, key) if key == &MSG_KEY_LEFT => {
|
(COMPONENT_EXPLORER_REMOTE, key) if key == &MSG_KEY_LEFT => {
|
||||||
// Change tab
|
// Change tab
|
||||||
self.view.active(COMPONENT_EXPLORER_LOCAL);
|
self.view.active(COMPONENT_EXPLORER_LOCAL);
|
||||||
@@ -336,6 +356,24 @@ impl Update for FileTransferActivity {
|
|||||||
None
|
None
|
||||||
}
|
}
|
||||||
// -- find result explorer
|
// -- find result explorer
|
||||||
|
(COMPONENT_EXPLORER_FIND, key)
|
||||||
|
if key == &MSG_KEY_RIGHT
|
||||||
|
&& matches!(self.browser.tab(), FileExplorerTab::FindLocal) =>
|
||||||
|
{
|
||||||
|
// Active remote explorer
|
||||||
|
self.view.active(COMPONENT_EXPLORER_REMOTE);
|
||||||
|
self.browser.change_tab(FileExplorerTab::Remote);
|
||||||
|
None
|
||||||
|
}
|
||||||
|
(COMPONENT_EXPLORER_FIND, key)
|
||||||
|
if key == &MSG_KEY_LEFT
|
||||||
|
&& matches!(self.browser.tab(), FileExplorerTab::FindRemote) =>
|
||||||
|
{
|
||||||
|
// Active local explorer
|
||||||
|
self.view.active(COMPONENT_EXPLORER_LOCAL);
|
||||||
|
self.browser.change_tab(FileExplorerTab::Local);
|
||||||
|
None
|
||||||
|
}
|
||||||
(COMPONENT_EXPLORER_FIND, key) if key == &MSG_KEY_ESC => {
|
(COMPONENT_EXPLORER_FIND, key) if key == &MSG_KEY_ESC => {
|
||||||
// Umount find
|
// Umount find
|
||||||
self.umount_find();
|
self.umount_find();
|
||||||
@@ -457,7 +495,13 @@ impl Update for FileTransferActivity {
|
|||||||
}
|
}
|
||||||
Ok(files) => {
|
Ok(files) => {
|
||||||
// Create explorer and load files
|
// Create explorer and load files
|
||||||
self.browser.set_found(files);
|
self.browser.set_found(
|
||||||
|
match self.browser.tab() {
|
||||||
|
FileExplorerTab::Local => FoundExplorerTab::Local,
|
||||||
|
_ => FoundExplorerTab::Remote,
|
||||||
|
},
|
||||||
|
files,
|
||||||
|
);
|
||||||
// Mount result widget
|
// Mount result widget
|
||||||
self.mount_find(input);
|
self.mount_find(input);
|
||||||
self.update_find_list();
|
self.update_find_list();
|
||||||
|
|||||||
@@ -26,7 +26,10 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
// locals
|
// locals
|
||||||
use super::{browser::FileExplorerTab, Context, FileTransferActivity};
|
use super::{
|
||||||
|
browser::{FileExplorerTab, FoundExplorerTab},
|
||||||
|
Context, FileTransferActivity,
|
||||||
|
};
|
||||||
use crate::fs::explorer::FileSorting;
|
use crate::fs::explorer::FileSorting;
|
||||||
use crate::fs::FsEntry;
|
use crate::fs::FsEntry;
|
||||||
use crate::ui::components::{
|
use crate::ui::components::{
|
||||||
@@ -165,24 +168,20 @@ impl FileTransferActivity {
|
|||||||
}
|
}
|
||||||
// Draw explorers
|
// Draw explorers
|
||||||
// @! Local explorer (Find or default)
|
// @! Local explorer (Find or default)
|
||||||
match self.browser.tab() {
|
if matches!(self.browser.found_tab(), Some(FoundExplorerTab::Local)) {
|
||||||
FileExplorerTab::FindLocal => {
|
self.view
|
||||||
self.view
|
.render(super::COMPONENT_EXPLORER_FIND, f, tabs_chunks[0]);
|
||||||
.render(super::COMPONENT_EXPLORER_FIND, f, tabs_chunks[0])
|
} else {
|
||||||
}
|
self.view
|
||||||
_ => self
|
.render(super::COMPONENT_EXPLORER_LOCAL, f, tabs_chunks[0]);
|
||||||
.view
|
|
||||||
.render(super::COMPONENT_EXPLORER_LOCAL, f, tabs_chunks[0]),
|
|
||||||
}
|
}
|
||||||
// @! Remote explorer (Find or default)
|
// @! Remote explorer (Find or default)
|
||||||
match self.browser.tab() {
|
if matches!(self.browser.found_tab(), Some(FoundExplorerTab::Remote)) {
|
||||||
FileExplorerTab::FindRemote => {
|
self.view
|
||||||
self.view
|
.render(super::COMPONENT_EXPLORER_FIND, f, tabs_chunks[1]);
|
||||||
.render(super::COMPONENT_EXPLORER_FIND, f, tabs_chunks[1])
|
} else {
|
||||||
}
|
self.view
|
||||||
_ => self
|
.render(super::COMPONENT_EXPLORER_REMOTE, f, tabs_chunks[1]);
|
||||||
.view
|
|
||||||
.render(super::COMPONENT_EXPLORER_REMOTE, f, tabs_chunks[1]),
|
|
||||||
}
|
}
|
||||||
// Draw log box
|
// Draw log box
|
||||||
self.view
|
self.view
|
||||||
|
|||||||
Reference in New Issue
Block a user