diff options
author | Jiayi Zhao <jeff.no.zhao@gmail.com> | 2020-08-29 22:06:19 -0400 |
---|---|---|
committer | Jiayi Zhao <jeff.no.zhao@gmail.com> | 2020-08-29 22:08:23 -0400 |
commit | 5be4a5f472655a76e1430bad09a19f6ad111e474 (patch) | |
tree | 1fcffa6c8d37cc6d538b29b6fbd773e8de58512d /src/fs | |
parent | 4f3842b56f1729dcd8e81c77f98253ed9dfb23b3 (diff) |
big rework and dependency update
- abstract JoshutoContext implementation behind functions
- rework io workers in an attempt to fix a bug
- update dependencies
- remove JoshutoContextWorker
Diffstat (limited to 'src/fs')
-rw-r--r-- | src/fs/dirlist.rs | 13 | ||||
-rw-r--r-- | src/fs/entry.rs | 14 |
2 files changed, 18 insertions, 9 deletions
diff --git a/src/fs/dirlist.rs b/src/fs/dirlist.rs index df42b9a..65e2db0 100644 --- a/src/fs/dirlist.rs +++ b/src/fs/dirlist.rs @@ -1,3 +1,4 @@ +use std::slice::{Iter, IterMut}; use std::{fs, path}; use crate::fs::{JoshutoDirEntry, JoshutoMetadata}; @@ -31,6 +32,14 @@ impl JoshutoDirList { }) } + pub fn iter(&self) -> Iter<JoshutoDirEntry> { + self.contents.iter() + } + + pub fn iter_mut(&mut self) -> IterMut<JoshutoDirEntry> { + self.contents.iter_mut() + } + pub fn modified(&self) -> bool { let metadata = std::fs::symlink_metadata(self.path.as_path()); match metadata { @@ -91,8 +100,8 @@ impl JoshutoDirList { self.contents.iter().filter(|entry| entry.is_selected()) } - pub fn get_selected_paths(&self) -> Vec<&path::PathBuf> { - let vec: Vec<&path::PathBuf> = self.selected_entries().map(|e| e.file_path()).collect(); + pub fn get_selected_paths(&self) -> Vec<&path::Path> { + let vec: Vec<&path::Path> = self.selected_entries().map(|e| e.file_path()).collect(); if !vec.is_empty() { vec } else { diff --git a/src/fs/entry.rs b/src/fs/entry.rs index cae0f85..4e6c69f 100644 --- a/src/fs/entry.rs +++ b/src/fs/entry.rs @@ -44,8 +44,8 @@ impl JoshutoDirEntry { self.name.as_str() } - pub fn file_path(&self) -> &path::PathBuf { - &self.path + pub fn file_path(&self) -> &path::Path { + self.path.as_path() } /* @@ -96,22 +96,22 @@ impl JoshutoDirEntry { Style::default() .fg(THEME_T.selection.fg) .bg(THEME_T.selection.bg) - .modifier(THEME_T.selection.modifier) + .add_modifier(THEME_T.selection.modifier) } else if filetype.is_dir() { Style::default() .fg(THEME_T.directory.fg) .bg(THEME_T.directory.bg) - .modifier(THEME_T.directory.modifier) + .add_modifier(THEME_T.directory.modifier) } else if filetype.is_symlink() { Style::default() .fg(THEME_T.link.fg) .bg(THEME_T.link.bg) - .modifier(THEME_T.link.modifier) + .add_modifier(THEME_T.link.modifier) } else if unix::is_executable(metadata.mode) { Style::default() .fg(THEME_T.executable.fg) .bg(THEME_T.executable.bg) - .modifier(THEME_T.executable.modifier) + .add_modifier(THEME_T.executable.modifier) } else { match self.file_path().extension() { None => Style::default(), @@ -119,7 +119,7 @@ impl JoshutoDirEntry { None => Style::default(), Some(s) => match THEME_T.ext.get(s) { None => Style::default(), - Some(t) => Style::default().fg(t.fg).bg(t.bg).modifier(t.modifier), + Some(t) => Style::default().fg(t.fg).bg(t.bg).add_modifier(t.modifier), }, }, } |