mirror of
https://github.com/veeso/termscp.git
synced 2025-12-07 09:36:00 -08:00
Status bar improvements: 'Show hidden files' in status bar; Status bar is has now been splitted into two, one for each explorer tab
This commit is contained in:
@@ -28,6 +28,9 @@ Released on FIXME: ??
|
|||||||
- Found many bugs which has now been fixed
|
- Found many bugs which has now been fixed
|
||||||
- Build in CI won't fail due to test servers not responding
|
- Build in CI won't fail due to test servers not responding
|
||||||
- We're now able to test all the functionalities of the file transfers
|
- We're now able to test all the functionalities of the file transfers
|
||||||
|
- **Status bar improvements**
|
||||||
|
- "Show hidden files" in status bar
|
||||||
|
- Status bar is has now been splitted into two, one for each explorer tab
|
||||||
- Bugfix:
|
- Bugfix:
|
||||||
- Fixed broken input cursor when typing UTF8 characters (tui-realm 0.3.2)
|
- Fixed broken input cursor when typing UTF8 characters (tui-realm 0.3.2)
|
||||||
- Fixed [Issue 44](https://github.com/veeso/termscp/issues/44): Could not move files to other paths in FTP
|
- Fixed [Issue 44](https://github.com/veeso/termscp/issues/44): Could not move files to other paths in FTP
|
||||||
|
|||||||
@@ -306,6 +306,13 @@ impl FileExplorer {
|
|||||||
pub fn toggle_hidden_files(&mut self) {
|
pub fn toggle_hidden_files(&mut self) {
|
||||||
self.opts.toggle(ExplorerOpts::SHOW_HIDDEN_FILES);
|
self.opts.toggle(ExplorerOpts::SHOW_HIDDEN_FILES);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// ### hidden_files_visible
|
||||||
|
///
|
||||||
|
/// Returns whether hidden files are visible
|
||||||
|
pub fn hidden_files_visible(&self) -> bool {
|
||||||
|
self.opts.intersects(ExplorerOpts::SHOW_HIDDEN_FILES)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Traits
|
// Traits
|
||||||
@@ -411,6 +418,7 @@ mod tests {
|
|||||||
let mut explorer: FileExplorer = FileExplorer::default();
|
let mut explorer: FileExplorer = FileExplorer::default();
|
||||||
// Don't show hidden files
|
// Don't show hidden files
|
||||||
explorer.opts.remove(ExplorerOpts::SHOW_HIDDEN_FILES);
|
explorer.opts.remove(ExplorerOpts::SHOW_HIDDEN_FILES);
|
||||||
|
assert_eq!(explorer.hidden_files_visible(), false);
|
||||||
// Create files
|
// Create files
|
||||||
explorer.set_files(vec![
|
explorer.set_files(vec![
|
||||||
make_fs_entry("README.md", false),
|
make_fs_entry("README.md", false),
|
||||||
@@ -434,6 +442,7 @@ mod tests {
|
|||||||
assert_eq!(explorer.iter_files().count(), 4);
|
assert_eq!(explorer.iter_files().count(), 4);
|
||||||
// Toggle hidden
|
// Toggle hidden
|
||||||
explorer.toggle_hidden_files();
|
explorer.toggle_hidden_files();
|
||||||
|
assert_eq!(explorer.hidden_files_visible(), true);
|
||||||
assert_eq!(explorer.iter_files().count(), 6); // All files are returned now
|
assert_eq!(explorer.iter_files().count(), 6); // All files are returned now
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -88,7 +88,8 @@ const COMPONENT_RADIO_DELETE: &str = "RADIO_DELETE";
|
|||||||
const COMPONENT_RADIO_DISCONNECT: &str = "RADIO_DISCONNECT";
|
const COMPONENT_RADIO_DISCONNECT: &str = "RADIO_DISCONNECT";
|
||||||
const COMPONENT_RADIO_QUIT: &str = "RADIO_QUIT";
|
const COMPONENT_RADIO_QUIT: &str = "RADIO_QUIT";
|
||||||
const COMPONENT_RADIO_SORTING: &str = "RADIO_SORTING";
|
const COMPONENT_RADIO_SORTING: &str = "RADIO_SORTING";
|
||||||
const COMPONENT_SPAN_STATUS_BAR: &str = "STATUS_BAR";
|
const COMPONENT_SPAN_STATUS_BAR_LOCAL: &str = "STATUS_BAR_LOCAL";
|
||||||
|
const COMPONENT_SPAN_STATUS_BAR_REMOTE: &str = "STATUS_BAR_REMOTE";
|
||||||
const COMPONENT_LIST_FILEINFO: &str = "LIST_FILEINFO";
|
const COMPONENT_LIST_FILEINFO: &str = "LIST_FILEINFO";
|
||||||
|
|
||||||
/// ## LogLevel
|
/// ## LogLevel
|
||||||
|
|||||||
@@ -107,6 +107,8 @@ impl Update for FileTransferActivity {
|
|||||||
(COMPONENT_EXPLORER_LOCAL, &MSG_KEY_CHAR_A) => {
|
(COMPONENT_EXPLORER_LOCAL, &MSG_KEY_CHAR_A) => {
|
||||||
// Toggle hidden files
|
// Toggle hidden files
|
||||||
self.local_mut().toggle_hidden_files();
|
self.local_mut().toggle_hidden_files();
|
||||||
|
// Update status bar
|
||||||
|
self.refresh_local_status_bar();
|
||||||
// Reload file list component
|
// Reload file list component
|
||||||
self.update_local_filelist()
|
self.update_local_filelist()
|
||||||
}
|
}
|
||||||
@@ -180,6 +182,8 @@ impl Update for FileTransferActivity {
|
|||||||
(COMPONENT_EXPLORER_REMOTE, &MSG_KEY_CHAR_A) => {
|
(COMPONENT_EXPLORER_REMOTE, &MSG_KEY_CHAR_A) => {
|
||||||
// Toggle hidden files
|
// Toggle hidden files
|
||||||
self.remote_mut().toggle_hidden_files();
|
self.remote_mut().toggle_hidden_files();
|
||||||
|
// Update status bar
|
||||||
|
self.refresh_remote_status_bar();
|
||||||
// Reload file list component
|
// Reload file list component
|
||||||
self.update_remote_filelist()
|
self.update_remote_filelist()
|
||||||
}
|
}
|
||||||
@@ -277,7 +281,7 @@ impl Update for FileTransferActivity {
|
|||||||
// Toggle browser sync
|
// Toggle browser sync
|
||||||
self.browser.toggle_sync_browsing();
|
self.browser.toggle_sync_browsing();
|
||||||
// Update status bar
|
// Update status bar
|
||||||
self.refresh_status_bar();
|
self.refresh_remote_status_bar();
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
(COMPONENT_EXPLORER_LOCAL, &MSG_KEY_ESC)
|
(COMPONENT_EXPLORER_LOCAL, &MSG_KEY_ESC)
|
||||||
@@ -618,7 +622,11 @@ impl Update for FileTransferActivity {
|
|||||||
_ => panic!("Found result doesn't support SORTING"),
|
_ => panic!("Found result doesn't support SORTING"),
|
||||||
}
|
}
|
||||||
// Update status bar
|
// Update status bar
|
||||||
self.refresh_status_bar();
|
match self.browser.tab() {
|
||||||
|
FileExplorerTab::Local => self.refresh_local_status_bar(),
|
||||||
|
FileExplorerTab::Remote => self.refresh_remote_status_bar(),
|
||||||
|
_ => panic!("Found result doesn't support SORTING"),
|
||||||
|
};
|
||||||
// Reload files
|
// Reload files
|
||||||
match self.browser.tab() {
|
match self.browser.tab() {
|
||||||
FileExplorerTab::Local => self.update_local_filelist(),
|
FileExplorerTab::Local => self.update_local_filelist(),
|
||||||
|
|||||||
@@ -100,13 +100,18 @@ impl FileTransferActivity {
|
|||||||
.build(),
|
.build(),
|
||||||
)),
|
)),
|
||||||
);
|
);
|
||||||
// Mount status bar
|
// Mount status bars
|
||||||
self.view.mount(
|
self.view.mount(
|
||||||
super::COMPONENT_SPAN_STATUS_BAR,
|
super::COMPONENT_SPAN_STATUS_BAR_LOCAL,
|
||||||
|
Box::new(Span::new(SpanPropsBuilder::default().build())),
|
||||||
|
);
|
||||||
|
self.view.mount(
|
||||||
|
super::COMPONENT_SPAN_STATUS_BAR_REMOTE,
|
||||||
Box::new(Span::new(SpanPropsBuilder::default().build())),
|
Box::new(Span::new(SpanPropsBuilder::default().build())),
|
||||||
);
|
);
|
||||||
// Load process bar
|
// Load process bar
|
||||||
self.refresh_status_bar();
|
self.refresh_local_status_bar();
|
||||||
|
self.refresh_remote_status_bar();
|
||||||
// Update components
|
// Update components
|
||||||
let _ = self.update_local_filelist();
|
let _ = self.update_local_filelist();
|
||||||
let _ = self.update_remote_filelist();
|
let _ = self.update_remote_filelist();
|
||||||
@@ -145,6 +150,12 @@ impl FileTransferActivity {
|
|||||||
.constraints([Constraint::Length(1), Constraint::Length(10)].as_ref())
|
.constraints([Constraint::Length(1), Constraint::Length(10)].as_ref())
|
||||||
.direction(Direction::Vertical)
|
.direction(Direction::Vertical)
|
||||||
.split(chunks[1]);
|
.split(chunks[1]);
|
||||||
|
// Create status bar chunks
|
||||||
|
let status_bar_chunks = Layout::default()
|
||||||
|
.constraints([Constraint::Percentage(50), Constraint::Percentage(50)].as_ref())
|
||||||
|
.direction(Direction::Horizontal)
|
||||||
|
.horizontal_margin(1)
|
||||||
|
.split(bottom_chunks[0]);
|
||||||
// If width is unset in the storage, set width
|
// If width is unset in the storage, set width
|
||||||
if !store.isset(super::STORAGE_EXPLORER_WIDTH) {
|
if !store.isset(super::STORAGE_EXPLORER_WIDTH) {
|
||||||
store.set_unsigned(super::STORAGE_EXPLORER_WIDTH, tabs_chunks[0].width as usize);
|
store.set_unsigned(super::STORAGE_EXPLORER_WIDTH, tabs_chunks[0].width as usize);
|
||||||
@@ -170,11 +181,20 @@ impl FileTransferActivity {
|
|||||||
.view
|
.view
|
||||||
.render(super::COMPONENT_EXPLORER_REMOTE, f, tabs_chunks[1]),
|
.render(super::COMPONENT_EXPLORER_REMOTE, f, tabs_chunks[1]),
|
||||||
}
|
}
|
||||||
// Draw log box and status bar
|
// Draw log box
|
||||||
self.view
|
self.view
|
||||||
.render(super::COMPONENT_LOG_BOX, f, bottom_chunks[1]);
|
.render(super::COMPONENT_LOG_BOX, f, bottom_chunks[1]);
|
||||||
self.view
|
// Draw status bar
|
||||||
.render(super::COMPONENT_SPAN_STATUS_BAR, f, bottom_chunks[0]);
|
self.view.render(
|
||||||
|
super::COMPONENT_SPAN_STATUS_BAR_LOCAL,
|
||||||
|
f,
|
||||||
|
status_bar_chunks[0],
|
||||||
|
);
|
||||||
|
self.view.render(
|
||||||
|
super::COMPONENT_SPAN_STATUS_BAR_REMOTE,
|
||||||
|
f,
|
||||||
|
status_bar_chunks[1],
|
||||||
|
);
|
||||||
// @! Draw popups
|
// @! Draw popups
|
||||||
if let Some(props) = self.view.get_props(super::COMPONENT_INPUT_COPY) {
|
if let Some(props) = self.view.get_props(super::COMPONENT_INPUT_COPY) {
|
||||||
if props.visible {
|
if props.visible {
|
||||||
@@ -840,9 +860,54 @@ impl FileTransferActivity {
|
|||||||
self.view.umount(super::COMPONENT_LIST_FILEINFO);
|
self.view.umount(super::COMPONENT_LIST_FILEINFO);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn refresh_status_bar(&mut self) {
|
pub(super) fn refresh_local_status_bar(&mut self) {
|
||||||
let bar_spans: Vec<TextSpan> = vec![
|
let local_bar_spans: Vec<TextSpan> = vec![
|
||||||
TextSpanBuilder::new("Synchronized Browsing: ")
|
TextSpanBuilder::new("File sorting: ")
|
||||||
|
.with_foreground(Color::LightYellow)
|
||||||
|
.build(),
|
||||||
|
TextSpanBuilder::new(Self::get_file_sorting_str(self.local().get_file_sorting()))
|
||||||
|
.with_foreground(Color::LightYellow)
|
||||||
|
.reversed()
|
||||||
|
.build(),
|
||||||
|
TextSpanBuilder::new(" Hidden files: ")
|
||||||
|
.with_foreground(Color::LightBlue)
|
||||||
|
.build(),
|
||||||
|
TextSpanBuilder::new(Self::get_hidden_files_str(
|
||||||
|
self.local().hidden_files_visible(),
|
||||||
|
))
|
||||||
|
.with_foreground(Color::LightBlue)
|
||||||
|
.reversed()
|
||||||
|
.build(),
|
||||||
|
];
|
||||||
|
if let Some(props) = self.view.get_props(super::COMPONENT_SPAN_STATUS_BAR_LOCAL) {
|
||||||
|
self.view.update(
|
||||||
|
super::COMPONENT_SPAN_STATUS_BAR_LOCAL,
|
||||||
|
SpanPropsBuilder::from(props)
|
||||||
|
.with_spans(local_bar_spans)
|
||||||
|
.build(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(super) fn refresh_remote_status_bar(&mut self) {
|
||||||
|
let remote_bar_spans: Vec<TextSpan> = vec![
|
||||||
|
TextSpanBuilder::new("File sorting: ")
|
||||||
|
.with_foreground(Color::LightYellow)
|
||||||
|
.build(),
|
||||||
|
TextSpanBuilder::new(Self::get_file_sorting_str(self.remote().get_file_sorting()))
|
||||||
|
.with_foreground(Color::LightYellow)
|
||||||
|
.reversed()
|
||||||
|
.build(),
|
||||||
|
TextSpanBuilder::new(" Hidden files: ")
|
||||||
|
.with_foreground(Color::LightBlue)
|
||||||
|
.build(),
|
||||||
|
TextSpanBuilder::new(Self::get_hidden_files_str(
|
||||||
|
self.remote().hidden_files_visible(),
|
||||||
|
))
|
||||||
|
.with_foreground(Color::LightBlue)
|
||||||
|
.reversed()
|
||||||
|
.build(),
|
||||||
|
TextSpanBuilder::new(" Sync Browsing: ")
|
||||||
.with_foreground(Color::LightGreen)
|
.with_foreground(Color::LightGreen)
|
||||||
.build(),
|
.build(),
|
||||||
TextSpanBuilder::new(match self.browser.sync_browsing {
|
TextSpanBuilder::new(match self.browser.sync_browsing {
|
||||||
@@ -852,25 +917,13 @@ impl FileTransferActivity {
|
|||||||
.with_foreground(Color::LightGreen)
|
.with_foreground(Color::LightGreen)
|
||||||
.reversed()
|
.reversed()
|
||||||
.build(),
|
.build(),
|
||||||
TextSpanBuilder::new(" Localhost file sorting: ")
|
|
||||||
.with_foreground(Color::LightYellow)
|
|
||||||
.build(),
|
|
||||||
TextSpanBuilder::new(Self::get_file_sorting_str(self.local().get_file_sorting()))
|
|
||||||
.with_foreground(Color::LightYellow)
|
|
||||||
.reversed()
|
|
||||||
.build(),
|
|
||||||
TextSpanBuilder::new(" Remote host file sorting: ")
|
|
||||||
.with_foreground(Color::LightBlue)
|
|
||||||
.build(),
|
|
||||||
TextSpanBuilder::new(Self::get_file_sorting_str(self.remote().get_file_sorting()))
|
|
||||||
.with_foreground(Color::LightBlue)
|
|
||||||
.reversed()
|
|
||||||
.build(),
|
|
||||||
];
|
];
|
||||||
if let Some(props) = self.view.get_props(super::COMPONENT_SPAN_STATUS_BAR) {
|
if let Some(props) = self.view.get_props(super::COMPONENT_SPAN_STATUS_BAR_REMOTE) {
|
||||||
self.view.update(
|
self.view.update(
|
||||||
super::COMPONENT_SPAN_STATUS_BAR,
|
super::COMPONENT_SPAN_STATUS_BAR_REMOTE,
|
||||||
SpanPropsBuilder::from(props).with_spans(bar_spans).build(),
|
SpanPropsBuilder::from(props)
|
||||||
|
.with_spans(remote_bar_spans)
|
||||||
|
.build(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1128,4 +1181,11 @@ impl FileTransferActivity {
|
|||||||
FileSorting::BySize => "By size",
|
FileSorting::BySize => "By size",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn get_hidden_files_str(show: bool) -> &'static str {
|
||||||
|
match show {
|
||||||
|
true => "Show",
|
||||||
|
false => "Hide",
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user