diff options
-rw-r--r-- | src/mode.rs | 15 | ||||
-rw-r--r-- | src/term_manager.rs | 26 |
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(()) } |