diff options
author | qkzk <qu3nt1n@gmail.com> | 2023-11-12 18:11:29 +0100 |
---|---|---|
committer | qkzk <qu3nt1n@gmail.com> | 2023-11-12 18:11:29 +0100 |
commit | 920479a6618e21eda36188197dce3e0b48630445 (patch) | |
tree | 61291a23b3aa8b6f5feaa14f1cb7a91758b78ddd | |
parent | 0035f68224db9d7bb9a976fc3c95dc59e3a1adb7 (diff) |
improve trash confirm draw
-rw-r--r-- | src/term_manager.rs | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/src/term_manager.rs b/src/term_manager.rs index 0c3926d..d1cbda7 100644 --- a/src/term_manager.rs +++ b/src/term_manager.rs @@ -1001,21 +1001,30 @@ impl<'a> WinSecondary<'a> { fn draw_confirm_empty_trash(&self, canvas: &mut dyn Canvas) -> Result<()> { if self.status.trash.is_empty() { - let _ = canvas.print_with_attr( - ContentWindow::WINDOW_MARGIN_TOP + 2, - 4, - "Trash is empty", - ATTR_YELLOW_BOLD, - ); + self.draw_already_empty_trash(canvas) } else { - for (row, trashinfo) in self.status.trash.content().iter().enumerate() { - canvas.print_with_attr( - row + ContentWindow::WINDOW_MARGIN_TOP + 2, - 4, - &format!("{trashinfo}"), - Attr::default(), - )?; - } + self.draw_confirm_non_empty_trash(canvas)? + } + Ok(()) + } + + fn draw_already_empty_trash(&self, canvas: &mut dyn Canvas) { + let _ = canvas.print_with_attr( + ContentWindow::WINDOW_MARGIN_TOP + 2, + 4, + "Trash is empty", + ATTR_YELLOW_BOLD, + ); + } + + fn draw_confirm_non_empty_trash(&self, canvas: &mut dyn Canvas) -> Result<()> { + for (row, trashinfo) in self.status.trash.content().iter().enumerate() { + canvas.print_with_attr( + row + ContentWindow::WINDOW_MARGIN_TOP + 2, + 4, + &format!("{trashinfo}"), + Attr::default(), + )?; } Ok(()) } |