feat: Toggle showing hidden items
`ctrl` + `h` toggles the visibility of hidden files and folders per tab. The per tab option overrides the global option. So, a user may set hidden items to be visible by default (global option) but override it per tab with `ctrl` + `h`. Currently, per tab options aren't presented anywhere in the UI such as a menu, so the hotkey is the only way to use this feature for now.
This commit is contained in:
parent
073a9a95ab
commit
bc5b46d552
4 changed files with 15 additions and 8 deletions
|
|
@ -61,6 +61,7 @@ pub enum Action {
|
||||||
TabPrev,
|
TabPrev,
|
||||||
TabViewGrid,
|
TabViewGrid,
|
||||||
TabViewList,
|
TabViewList,
|
||||||
|
ToggleShowHidden,
|
||||||
WindowClose,
|
WindowClose,
|
||||||
WindowNew,
|
WindowNew,
|
||||||
}
|
}
|
||||||
|
|
@ -91,6 +92,7 @@ impl Action {
|
||||||
Action::TabViewList => {
|
Action::TabViewList => {
|
||||||
Message::TabMessage(entity_opt, tab::Message::View(tab::View::List))
|
Message::TabMessage(entity_opt, tab::Message::View(tab::View::List))
|
||||||
}
|
}
|
||||||
|
Action::ToggleShowHidden => Message::TabMessage(None, tab::Message::ToggleShowHidden),
|
||||||
Action::WindowClose => Message::WindowClose,
|
Action::WindowClose => Message::WindowClose,
|
||||||
Action::WindowNew => Message::WindowNew,
|
Action::WindowNew => Message::WindowNew,
|
||||||
}
|
}
|
||||||
|
|
@ -681,8 +683,7 @@ impl Application for App {
|
||||||
if let Some(tab) = self.tab_model.data_mut::<Tab>(entity) {
|
if let Some(tab) = self.tab_model.data_mut::<Tab>(entity) {
|
||||||
if let Some(ref mut items) = tab.items_opt {
|
if let Some(ref mut items) = tab.items_opt {
|
||||||
for item in items.iter_mut() {
|
for item in items.iter_mut() {
|
||||||
if item.hidden {
|
if !tab.config.show_hidden && item.hidden {
|
||||||
//TODO: option to show hidden files
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
item.selected = true;
|
item.selected = true;
|
||||||
|
|
|
||||||
|
|
@ -349,8 +349,7 @@ impl Application for App {
|
||||||
if let Some(tab) = self.tab_model.data_mut::<Tab>(entity) {
|
if let Some(tab) = self.tab_model.data_mut::<Tab>(entity) {
|
||||||
if let Some(ref mut items) = tab.items_opt {
|
if let Some(ref mut items) = tab.items_opt {
|
||||||
for item in items.iter_mut() {
|
for item in items.iter_mut() {
|
||||||
if item.hidden {
|
if !tab.config.show_hidden && item.hidden {
|
||||||
//TODO: option to show hidden files
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
item.selected = true;
|
item.selected = true;
|
||||||
|
|
|
||||||
|
|
@ -71,6 +71,7 @@ pub fn key_binds() -> HashMap<KeyBind, Action> {
|
||||||
bind!([Ctrl], Key::Character("t".into()), TabNew);
|
bind!([Ctrl], Key::Character("t".into()), TabNew);
|
||||||
bind!([Ctrl], Key::Named(Named::Tab), TabNext);
|
bind!([Ctrl], Key::Named(Named::Tab), TabNext);
|
||||||
bind!([Ctrl, Shift], Key::Named(Named::Tab), TabPrev);
|
bind!([Ctrl, Shift], Key::Named(Named::Tab), TabPrev);
|
||||||
|
bind!([Ctrl], Key::Character("h".into()), ToggleShowHidden);
|
||||||
bind!([Ctrl], Key::Character("q".into()), WindowClose);
|
bind!([Ctrl], Key::Character("q".into()), WindowClose);
|
||||||
bind!([Ctrl], Key::Character("n".into()), WindowNew);
|
bind!([Ctrl], Key::Character("n".into()), WindowNew);
|
||||||
|
|
||||||
|
|
|
||||||
14
src/tab.rs
14
src/tab.rs
|
|
@ -380,12 +380,14 @@ impl Location {
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub enum Message {
|
pub enum Message {
|
||||||
Click(Option<usize>),
|
Click(Option<usize>),
|
||||||
|
Config(TabConfig),
|
||||||
EditLocation(Option<Location>),
|
EditLocation(Option<Location>),
|
||||||
GoNext,
|
GoNext,
|
||||||
GoPrevious,
|
GoPrevious,
|
||||||
Location(Location),
|
Location(Location),
|
||||||
LocationUp,
|
LocationUp,
|
||||||
RightClick(usize),
|
RightClick(usize),
|
||||||
|
ToggleShowHidden,
|
||||||
View(View),
|
View(View),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -603,6 +605,9 @@ impl Tab {
|
||||||
}
|
}
|
||||||
self.context_menu = None;
|
self.context_menu = None;
|
||||||
}
|
}
|
||||||
|
Message::Config(config) => {
|
||||||
|
self.config = config;
|
||||||
|
}
|
||||||
Message::EditLocation(edit_location) => {
|
Message::EditLocation(edit_location) => {
|
||||||
self.edit_location = edit_location;
|
self.edit_location = edit_location;
|
||||||
}
|
}
|
||||||
|
|
@ -651,6 +656,7 @@ impl Tab {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Message::ToggleShowHidden => self.config.show_hidden = !self.config.show_hidden,
|
||||||
Message::View(view) => {
|
Message::View(view) => {
|
||||||
self.view = view;
|
self.view = view;
|
||||||
}
|
}
|
||||||
|
|
@ -859,15 +865,15 @@ impl Tab {
|
||||||
//TODO: get from config
|
//TODO: get from config
|
||||||
let item_width = Length::Fixed(96.0);
|
let item_width = Length::Fixed(96.0);
|
||||||
let item_height = Length::Fixed(116.0);
|
let item_height = Length::Fixed(116.0);
|
||||||
|
let TabConfig { show_hidden } = self.config;
|
||||||
|
|
||||||
let mut children: Vec<Element<_>> = Vec::new();
|
let mut children: Vec<Element<_>> = Vec::new();
|
||||||
if let Some(ref items) = self.items_opt {
|
if let Some(ref items) = self.items_opt {
|
||||||
let mut count = 0;
|
let mut count = 0;
|
||||||
let mut hidden = 0;
|
let mut hidden = 0;
|
||||||
for (i, item) in items.iter().enumerate() {
|
for (i, item) in items.iter().enumerate() {
|
||||||
if item.hidden {
|
if !show_hidden && item.hidden {
|
||||||
hidden += 1;
|
hidden += 1;
|
||||||
//TODO: SHOW HIDDEN OPTION
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -942,10 +948,10 @@ impl Tab {
|
||||||
if let Some(ref items) = self.items_opt {
|
if let Some(ref items) = self.items_opt {
|
||||||
let mut count = 0;
|
let mut count = 0;
|
||||||
let mut hidden = 0;
|
let mut hidden = 0;
|
||||||
|
let TabConfig { show_hidden } = self.config;
|
||||||
for (i, item) in items.iter().enumerate() {
|
for (i, item) in items.iter().enumerate() {
|
||||||
if item.hidden {
|
if !show_hidden && item.hidden {
|
||||||
hidden += 1;
|
hidden += 1;
|
||||||
//TODO: SHOW HIDDEN OPTION
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue