summaryrefslogtreecommitdiffstats
path: root/src/interactive
diff options
context:
space:
mode:
authorVinzent Steinberg <Vinzent.Steinberg@gmail.com>2019-07-24 15:29:55 +0200
committerVinzent Steinberg <Vinzent.Steinberg@gmail.com>2019-07-24 15:29:55 +0200
commit3baf7f31b91c71ba0acb2be886a47ccbd2b295fb (patch)
treee704edc5e73085139f8a3747bac05ce1d9866a0d /src/interactive
parent977e69f9aafc54f9b2ed9ddb2eee5164e30b213c (diff)
Use same colors in mark pane as in entries pane
This required passing the information whether a path is a directory accordingly.
Diffstat (limited to 'src/interactive')
-rw-r--r--src/interactive/app/handlers.rs13
-rw-r--r--src/interactive/widgets/mark.rs6
2 files changed, 10 insertions, 9 deletions
diff --git a/src/interactive/app/handlers.rs b/src/interactive/app/handlers.rs
index 9a0f7f6..67a9b8e 100644
--- a/src/interactive/app/handlers.rs
+++ b/src/interactive/app/handlers.rs
@@ -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)
diff --git a/src/interactive/widgets/mark.rs b/src/interactive/widgets/mark.rs
index 49a4128..702c187 100644
--- a/src/interactive/widgets/mark.rs
+++ b/src/interactive/widgets/mark.rs
@@ -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)]
@@ -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) {
@@ -73,6 +74,7 @@ impl MarkPane {
path: path_of(tree, index),
index: sorting_index,
num_errors_during_deletion: 0,
+ is_dir,
});
}
}
@@ -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 {