From 1fdded129fe766729ac332fa881c0681c9495316 Mon Sep 17 00:00:00 2001 From: Lewis Cook Date: Tue, 13 Jul 2021 10:06:15 +0100 Subject: Make the trash feature optional --- Cargo.toml | 5 +++-- src/interactive/app/handlers.rs | 2 ++ src/interactive/widgets/help.rs | 1 + src/interactive/widgets/mark.rs | 4 ++++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 0c89614..43cb98c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,11 +10,12 @@ license = "MIT" include = ["src/**/*", "Cargo.*", "LICENSE", "README.md", "CHANGELOG.md", "!**/tests/*"] [features] -default = ["tui-crossplatform"] +default = ["tui-crossplatform", "trash-move"] tui-unix = ["crosstermion/tui-react-termion", "tui-shared"] tui-crossplatform = ["crosstermion/tui-react-crossterm", "tui-shared"] tui-shared = ["tui", "tui-react", "open", "unicode-segmentation"] +trash-move = ["trash"] [dependencies] clap = "3.0.0-beta.2" @@ -27,7 +28,7 @@ num_cpus = "1.10.0" filesize = "0.2.0" anyhow = "1.0.31" colored = "2.0.0" -trash = "2.0.1" +trash = { version = "2.0.1", optional = true } # 'tui' related unicode-segmentation = { version = "1.3.0", optional = true } 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/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", -- cgit v1.2.3