summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorqkzk <qu3nt1n@gmail.com>2023-09-23 14:42:08 +0200
committerqkzk <qu3nt1n@gmail.com>2023-09-23 14:42:08 +0200
commiteee6d1a8835d51d929b29da83c7466bc32f5029a (patch)
tree1271014c92c41a6853d45f6a8a6f899d0f4afda9
parent5ea0739aeec461d1d4365806c7280e350558bd9f (diff)
Needconfirmation mode are responsible of their confirmation message
-rw-r--r--src/mode.rs15
-rw-r--r--src/term_manager.rs26
2 files changed, 22 insertions, 19 deletions
diff --git a/src/mode.rs b/src/mode.rs
index 012f0a2..38cfa70 100644
--- a/src/mode.rs
+++ b/src/mode.rs
@@ -41,6 +41,21 @@ impl NeedConfirmation {
Self::EmptyTrash => 35,
}
}
+
+ /// A confirmation message to be displayed before executing the mode.
+ /// When files are moved or copied the destination is displayed.
+ pub fn confirmation_string(&self, destination: &str) -> String {
+ match *self {
+ NeedConfirmation::Copy => {
+ format!("Files will be copied to {}", destination)
+ }
+ NeedConfirmation::Delete => "Files will deleted permanently".to_owned(),
+ NeedConfirmation::Move => {
+ format!("Files will be moved to {}", destination)
+ }
+ NeedConfirmation::EmptyTrash => "Trash will be emptied".to_owned(),
+ }
+ }
}
impl std::fmt::Display for NeedConfirmation {
diff --git a/src/term_manager.rs b/src/term_manager.rs
index 49654b2..105255e 100644
--- a/src/term_manager.rs
+++ b/src/term_manager.rs
@@ -594,11 +594,7 @@ impl<'a> WinSecondary<'a> {
/// Display a cursor in the top row, at a correct column.
fn cursor(&self, tab: &Tab, canvas: &mut dyn Canvas) -> Result<()> {
match tab.mode {
- Mode::Normal
- | Mode::Tree
- | Mode::Navigate(Navigate::Marks(_))
- | Mode::Navigate(_)
- | Mode::Preview => {
+ Mode::Normal | Mode::Tree | Mode::Navigate(_) | Mode::Preview => {
canvas.show_cursor(false)?;
}
Mode::InputSimple(InputSimple::Sort) => {
@@ -844,20 +840,12 @@ impl<'a> WinSecondary<'a> {
}
}
}
- let confirmation_string = match confirmed_mode {
- NeedConfirmation::Copy => {
- format!(
- "Files will be copied to {}",
- tab.path_content.path_to_str()?
- )
- }
- NeedConfirmation::Delete => "Files will deleted permanently".to_owned(),
- NeedConfirmation::Move => {
- format!("Files will be moved to {}", tab.path_content.path_to_str()?)
- }
- NeedConfirmation::EmptyTrash => "Trash will be emptied".to_owned(),
- };
- canvas.print_with_attr(2, 3, &confirmation_string, ATTR_YELLOW_BOLD)?;
+ canvas.print_with_attr(
+ 2,
+ 3,
+ &confirmed_mode.confirmation_string(tab.path_content.path_to_str()?),
+ ATTR_YELLOW_BOLD,
+ )?;
Ok(())
}