summaryrefslogtreecommitdiffstats
path: root/src/fs
diff options
context:
space:
mode:
authorJeff Zhao <jeff.no.zhao@gmail.com>2021-04-29 19:43:07 -0400
committerJeff Zhao <jeff.no.zhao@gmail.com>2021-04-29 19:46:17 -0400
commit065ef4d5a1f5443de5726343323403477b0263b5 (patch)
tree5f9178bb33229b068c7e9b346d5b7e1c046b989b /src/fs
parent10394fd7a2fb41e9eb6bea36e57b5270d50e5cbf (diff)
rework config structure
- sort options is now nested under display options which holds a lot of previously general options - fix glob search not searching backwards
Diffstat (limited to 'src/fs')
-rw-r--r--src/fs/dirlist.rs22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/fs/dirlist.rs b/src/fs/dirlist.rs
index 279fcae..99e686c 100644
--- a/src/fs/dirlist.rs
+++ b/src/fs/dirlist.rs
@@ -2,7 +2,7 @@ use std::slice::{Iter, IterMut};
use std::{fs, path};
use crate::fs::{JoshutoDirEntry, JoshutoMetadata};
-use crate::util::sort::SortOption;
+use crate::util::display::DisplayOption;
#[derive(Debug)]
pub struct JoshutoDirList {
@@ -14,10 +14,12 @@ pub struct JoshutoDirList {
}
impl JoshutoDirList {
- pub fn new(path: path::PathBuf, sort_option: &SortOption) -> std::io::Result<Self> {
- let filter_func = sort_option.filter_func();
- let mut contents = read_dir_list(path.as_path(), filter_func, sort_option.show_icons)?;
- contents.sort_by(|f1, f2| sort_option.compare(f1, f2));
+ pub fn new(path: path::PathBuf, options: &DisplayOption) -> std::io::Result<Self> {
+ let filter_func = options.filter_func();
+ let mut contents = read_dir_list(path.as_path(), filter_func, options.show_icons())?;
+
+ let sort_options = options.sort_options_ref();
+ contents.sort_by(|f1, f2| sort_options.compare(f1, f2));
let index = if contents.is_empty() { None } else { Some(0) };
@@ -67,10 +69,12 @@ impl JoshutoDirList {
&self.path
}
- pub fn reload_contents(&mut self, sort_option: &SortOption) -> std::io::Result<()> {
- let filter_func = sort_option.filter_func();
- let mut contents = read_dir_list(self.file_path(), filter_func, sort_option.show_icons)?;
- contents.sort_by(|f1, f2| sort_option.compare(f1, f2));
+ pub fn reload_contents(&mut self, options: &DisplayOption) -> std::io::Result<()> {
+ let filter_func = options.filter_func();
+ let mut contents = read_dir_list(self.file_path(), filter_func, options.show_icons())?;
+
+ let sort_options = options.sort_options_ref();
+ contents.sort_by(|f1, f2| sort_options.compare(f1, f2));
let contents_len = contents.len();
let index: Option<usize> = if contents_len == 0 {