Skip to content

Commit

Permalink
Use same colors in mark pane as in entries pane
Browse files Browse the repository at this point in the history
This required passing the information whether a path is a directory
accordingly.
  • Loading branch information
vks committed Jul 24, 2019
1 parent 977e69f commit 3baf7f3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
13 changes: 6 additions & 7 deletions src/interactive/app/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,14 @@ impl TerminalApp {
}

pub fn mark_entry(&mut self, advance_cursor: bool) {
match (self.state.selected, self.window.mark_pane.take()) {
(Some(index), Some(pane)) => {
self.window.mark_pane = pane.toggle_index(index, &self.traversal.tree);
}
(Some(index), None) => {
if let Some(index) = self.state.selected {
let is_dir = self.state.entries.iter().find(|e| e.index == index).unwrap().is_dir;
if let Some(pane) = self.window.mark_pane.take() {
self.window.mark_pane = pane.toggle_index(index, &self.traversal.tree, is_dir);
} else {
self.window.mark_pane =
MarkPane::default().toggle_index(index, &self.traversal.tree)
MarkPane::default().toggle_index(index, &self.traversal.tree, is_dir)
}
_ => {}
};
if advance_cursor {
self.change_entry_selection(CursorDirection::Down)
Expand Down
6 changes: 4 additions & 2 deletions src/interactive/widgets/mark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ pub struct EntryMark {
pub path: PathBuf,
pub index: usize,
pub num_errors_during_deletion: usize,
pub is_dir: bool,
}

#[derive(Default)]
Expand Down Expand Up @@ -62,7 +63,7 @@ impl MarkPane {
self.selected = None
}
}
pub fn toggle_index(mut self, index: TreeIndex, tree: &Tree) -> Option<Self> {
pub fn toggle_index(mut self, index: TreeIndex, tree: &Tree, is_dir: bool) -> Option<Self> {
match self.marked.entry(index) {
Entry::Vacant(entry) => {
if let Some(e) = tree.node_weight(index) {
Expand All @@ -73,6 +74,7 @@ impl MarkPane {
path: path_of(tree, index),
index: sorting_index,
num_errors_during_deletion: 0,
is_dir,
});
}
}
Expand Down Expand Up @@ -258,7 +260,7 @@ impl MarkPane {
_ => (path, num_path_graphemes),
}
};
let fg_path = get_name_color(Color::Reset, false, true); // TODO: determine whether directory
let fg_path = get_name_color(Color::Reset, !v.is_dir, true);
let path = Text::Styled(
path.into(),
Style {
Expand Down

0 comments on commit 3baf7f3

Please sign in to comment.