summaryrefslogtreecommitdiffstats
path: root/src/interactive
diff options
context:
space:
mode:
Diffstat (limited to 'src/interactive')
-rw-r--r--src/interactive/app/handlers.rs2
-rw-r--r--src/interactive/app/tests/journeys_with_writes.rs14
-rw-r--r--src/interactive/widgets/help.rs1
-rw-r--r--src/interactive/widgets/mark.rs4
4 files changed, 11 insertions, 10 deletions
diff --git a/src/interactive/app/handlers.rs b/src/interactive/app/handlers.rs
index 73e7403..d36e5f8 100644
--- a/src/interactive/app/handlers.rs
+++ b/src/interactive/app/handlers.rs
@@ -229,6 +229,7 @@ impl AppState {
self.message = None;
res
}
+ #[cfg(feature = "trash-move")]
Some(MarkMode::Trash) => {
self.message = Some("Trashing entries...".to_string());
let mut entries_trashed = 0;
@@ -272,6 +273,7 @@ impl AppState {
Ok(entries_deleted)
}
+ #[cfg(feature = "trash-move")]
pub fn trash_entry(
&mut self,
index: TreeIndex,
diff --git a/src/interactive/app/tests/journeys_with_writes.rs b/src/interactive/app/tests/journeys_with_writes.rs
index d55b368..6e411f3 100644
--- a/src/interactive/app/tests/journeys_with_writes.rs
+++ b/src/interactive/app/tests/journeys_with_writes.rs
@@ -19,11 +19,7 @@ fn basic_user_journey_with_deletion() -> Result<()> {
"expecting 4 selected entries, the parent dir, and some children"
);
- assert_eq!(
- fixture.as_ref().is_dir(),
- true,
- "expecting fixture root to exist"
- );
+ assert!(fixture.as_ref().is_dir(), "expecting fixture root to exist");
// When selecting the marker window and pressing the combination to delete entries
app.process_events(
@@ -34,9 +30,8 @@ fn basic_user_journey_with_deletion() -> Result<()> {
]
.into_iter(),
)?;
- assert_eq!(
+ assert!(
app.window.mark_pane.is_none(),
- true,
"the marker pane is gone as all entries have been removed"
);
assert_eq!(app.state.selected, None, "nothing is left to be selected");
@@ -44,9 +39,8 @@ fn basic_user_journey_with_deletion() -> Result<()> {
app.state.root, app.traversal.root_index,
"the only root left is the top-level"
);
- assert_eq!(
- fixture.as_ref().is_dir(),
- false,
+ assert!(
+ !fixture.as_ref().is_dir(),
"the directory should have been deleted",
);
Ok(())
diff --git a/src/interactive/widgets/help.rs b/src/interactive/widgets/help.rs
index d410035..769cfda 100644
--- a/src/interactive/widgets/help.rs
+++ b/src/interactive/widgets/help.rs
@@ -168,6 +168,7 @@ impl HelpPane {
"Permanently delete all marked entries without prompt!",
Some("This operation cannot be undone!"),
);
+ #[cfg(feature = "trash-move")]
hotkey(
"Ctrl + t",
"Move all marked entries to the trash bin",
diff --git a/src/interactive/widgets/mark.rs b/src/interactive/widgets/mark.rs
index d80b311..0cc48f2 100644
--- a/src/interactive/widgets/mark.rs
+++ b/src/interactive/widgets/mark.rs
@@ -28,6 +28,7 @@ use unicode_segmentation::UnicodeSegmentation;
pub enum MarkMode {
Delete,
+ #[cfg(feature = "trash-move")]
Trash,
}
@@ -110,6 +111,7 @@ impl MarkPane {
let action = None;
match key {
Ctrl('r') => return Some(self.prepare_deletion(MarkMode::Delete)),
+ #[cfg(feature = "trash-move")]
Ctrl('t') => return Some(self.prepare_deletion(MarkMode::Trash)),
Char('x') | Char('d') | Char(' ') => {
return self.remove_selected().map(|s| (s, action))
@@ -360,6 +362,7 @@ impl MarkPane {
sub_modifier: Modifier::empty(),
};
Paragraph::new(Text::from(Spans::from(vec![
+ #[cfg(feature = "trash-move")]
Span::styled(
" Ctrl + t",
Style {
@@ -368,6 +371,7 @@ impl MarkPane {
..default_style
},
),
+ #[cfg(feature = "trash-move")]
Span::styled(" to trash or ", default_style),
Span::styled(
" Ctrl + r",