diff options
Diffstat (limited to 'src/commands/delete_files.rs')
-rw-r--r-- | src/commands/delete_files.rs | 30 |
1 files changed, 7 insertions, 23 deletions
diff --git a/src/commands/delete_files.rs b/src/commands/delete_files.rs index 8233ce2..ed35630 100644 --- a/src/commands/delete_files.rs +++ b/src/commands/delete_files.rs @@ -4,11 +4,8 @@ use std::path; use crate::commands::{JoshutoCommand, JoshutoRunnable, ReloadDirList}; use crate::context::JoshutoContext; use crate::error::JoshutoResult; -use crate::ui; +use crate::ui::TuiBackend; use crate::util::event::Event; -use crate::window::JoshutoView; - -use crate::KEYMAP_T; #[derive(Clone, Debug)] pub struct DeleteFiles; @@ -34,10 +31,7 @@ impl DeleteFiles { Ok(()) } - fn delete_files(context: &mut JoshutoContext, view: &JoshutoView) -> std::io::Result<()> { - ui::wprint_msg(&view.bot_win, "Delete selected files? (Y/n)"); - ncurses::doupdate(); - + fn delete_files(context: &mut JoshutoContext, backend: &mut TuiBackend) -> std::io::Result<()> { let curr_tab = &mut context.tabs[context.curr_tab_index]; let paths = curr_tab.curr_list.get_selected_paths(); if paths.is_empty() { @@ -51,11 +45,10 @@ impl DeleteFiles { while let Ok(evt) = context.events.next() { match evt { Event::Input(key) => { - if key == termion::event::Key::Char('y') || - key == termion::event::Key::Char('\n') { + if key == termion::event::Key::Char('y') + || key == termion::event::Key::Char('\n') + { if paths.len() > 1 { - ui::wprint_msg(&view.bot_win, "Are you sure? (y/N)"); - ncurses::doupdate(); while let Ok(evt) = context.events.next() { match evt { Event::Input(key) => { @@ -77,7 +70,6 @@ impl DeleteFiles { if ch == termion::event::Key::Char('y') { Self::remove_files(&paths)?; - ui::wprint_msg(&view.bot_win, "Deleted files"); ReloadDirList::reload(context.curr_tab_index, context)?; } Ok(()) @@ -93,16 +85,8 @@ impl std::fmt::Display for DeleteFiles { } impl JoshutoRunnable for DeleteFiles { - fn execute(&self, context: &mut JoshutoContext, view: &JoshutoView) -> JoshutoResult<()> { - Self::delete_files(context, view)?; - let curr_tab = &mut context.tabs[context.curr_tab_index]; - curr_tab.refresh_curr(&view.mid_win, &context.config_t); - if context.config_t.show_preview { - curr_tab.refresh_preview(&view.right_win, &context.config_t); - } - curr_tab.refresh_path_status(&view.top_win, &context.config_t); - curr_tab.refresh_file_status(&view.bot_win); - ncurses::doupdate(); + fn execute(&self, context: &mut JoshutoContext, backend: &mut TuiBackend) -> JoshutoResult<()> { + Self::delete_files(context, backend)?; Ok(()) } } |