feature(strider): Allow to Hide Hidden Files (#203)
closes #197 default keybinding = '.' default view = shows hidden files Alternative: Hide hidden files by default.
This commit is contained in:
parent
8d923ec6fd
commit
683c152fa2
2 changed files with 15 additions and 0 deletions
|
|
@ -61,6 +61,12 @@ impl ZellijTile for State {
|
||||||
self.path.pop();
|
self.path.pop();
|
||||||
refresh_directory(self);
|
refresh_directory(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Key::Char('.') => {
|
||||||
|
self.toggle_hidden_files();
|
||||||
|
refresh_directory(self);
|
||||||
|
}
|
||||||
|
|
||||||
_ => (),
|
_ => (),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -80,6 +86,7 @@ fn refresh_directory(state: &mut State) {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.ok()
|
.ok()
|
||||||
|
.filter(|d| !d.is_hidden_file() || !state.hide_hidden_files)
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ pub struct State {
|
||||||
pub path: PathBuf,
|
pub path: PathBuf,
|
||||||
pub files: Vec<FsEntry>,
|
pub files: Vec<FsEntry>,
|
||||||
pub cursor_hist: HashMap<PathBuf, (usize, usize)>,
|
pub cursor_hist: HashMap<PathBuf, (usize, usize)>,
|
||||||
|
pub hide_hidden_files: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl State {
|
impl State {
|
||||||
|
|
@ -21,6 +22,9 @@ impl State {
|
||||||
pub fn scroll(&self) -> usize {
|
pub fn scroll(&self) -> usize {
|
||||||
self.cursor_hist.get(&self.path).unwrap_or(&(0, 0)).1
|
self.cursor_hist.get(&self.path).unwrap_or(&(0, 0)).1
|
||||||
}
|
}
|
||||||
|
pub fn toggle_hidden_files(&mut self) {
|
||||||
|
self.hide_hidden_files = !self.hide_hidden_files;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(PartialEq, Eq, PartialOrd, Ord, Clone)]
|
#[derive(PartialEq, Eq, PartialOrd, Ord, Clone)]
|
||||||
|
|
@ -52,4 +56,8 @@ impl FsEntry {
|
||||||
[name, padding, info].concat()
|
[name, padding, info].concat()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn is_hidden_file(&self) -> bool {
|
||||||
|
self.name().chars().nth(0).unwrap() == '.'.into()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue