mirror of
https://github.com/veeso/termscp.git
synced 2025-12-07 09:36:00 -08:00
Use file_fmt in explorer activity
This commit is contained in:
@@ -24,6 +24,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// Locals
|
// Locals
|
||||||
|
use super::formatter::Formatter;
|
||||||
use super::{ExplorerOpts, FileExplorer, FileSorting, GroupDirs};
|
use super::{ExplorerOpts, FileExplorer, FileSorting, GroupDirs};
|
||||||
// Ext
|
// Ext
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
@@ -95,6 +96,18 @@ impl FileExplorerBuilder {
|
|||||||
}
|
}
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// ### with_formatter
|
||||||
|
///
|
||||||
|
/// Set formatter for FileExplorer
|
||||||
|
pub fn with_formatter(&mut self, fmt_str: Option<&str>) -> &mut FileExplorerBuilder {
|
||||||
|
if let Some(e) = self.explorer.as_mut() {
|
||||||
|
if let Some(fmt_str) = fmt_str {
|
||||||
|
e.fmt = Formatter::new(fmt_str);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
@@ -119,6 +132,7 @@ mod tests {
|
|||||||
.with_group_dirs(Some(GroupDirs::First))
|
.with_group_dirs(Some(GroupDirs::First))
|
||||||
.with_hidden_files(true)
|
.with_hidden_files(true)
|
||||||
.with_stack_size(24)
|
.with_stack_size(24)
|
||||||
|
.with_formatter(Some("{NAME}"))
|
||||||
.build();
|
.build();
|
||||||
// Verify
|
// Verify
|
||||||
assert!(explorer.opts.intersects(ExplorerOpts::SHOW_HIDDEN_FILES));
|
assert!(explorer.opts.intersects(ExplorerOpts::SHOW_HIDDEN_FILES));
|
||||||
|
|||||||
@@ -133,6 +133,7 @@ impl FileTransferActivity {
|
|||||||
.with_group_dirs(cli.get_group_dirs())
|
.with_group_dirs(cli.get_group_dirs())
|
||||||
.with_hidden_files(cli.get_show_hidden_files())
|
.with_hidden_files(cli.get_show_hidden_files())
|
||||||
.with_stack_size(16)
|
.with_stack_size(16)
|
||||||
|
.with_formatter(cli.get_file_fmt().as_deref())
|
||||||
.build(),
|
.build(),
|
||||||
None => FileExplorerBuilder::new() // Build default
|
None => FileExplorerBuilder::new() // Build default
|
||||||
.with_file_sorting(FileSorting::ByName)
|
.with_file_sorting(FileSorting::ByName)
|
||||||
|
|||||||
Reference in New Issue
Block a user