diff options
author | Jiayi Zhao <jeff.no.zhao@gmail.com> | 2020-02-09 12:39:31 -0500 |
---|---|---|
committer | Jiayi Zhao <jeff.no.zhao@gmail.com> | 2020-02-09 13:07:31 -0500 |
commit | becbb90b2f22d58c98693d653f55ba604bb03f75 (patch) | |
tree | 085b9ac9b197a9ad3f0dd20df36848c5619adefe /src/commands/delete_files.rs | |
parent | 656582a6c867c25667661be9b327b4cc73859d7d (diff) |
rework input thread and file operations
- no longer depend on fs_extra for copy/paste files
- in house solution preserves permissions
- ioworkers are now queued, no more parallel io tasks
- input thread now listens for ioworker threads as well
- cargo fmt
Diffstat (limited to 'src/commands/delete_files.rs')
-rw-r--r-- | src/commands/delete_files.rs | 35 |
1 files changed, 13 insertions, 22 deletions
diff --git a/src/commands/delete_files.rs b/src/commands/delete_files.rs index adaed07..c726dd4 100644 --- a/src/commands/delete_files.rs +++ b/src/commands/delete_files.rs @@ -35,32 +35,23 @@ impl DeleteFiles { fn delete_files(context: &mut JoshutoContext, view: &JoshutoView) -> std::io::Result<()> { ui::wprint_msg(&view.bot_win, "Delete selected files? (Y/n)"); - ncurses::timeout(-1); ncurses::doupdate(); let curr_tab = &mut context.tabs[context.curr_tab_index]; - let mut ch = ncurses::getch(); - if ch == 'y' as i32 || ch == KEYMAP_T.enter { - let paths = curr_tab.curr_list.get_selected_paths(); - if paths.is_empty() { - return Err(std::io::Error::new( - std::io::ErrorKind::Other, - "no files selected", - )); - } - if paths.len() > 1 { - ui::wprint_msg(&view.bot_win, "Are you sure? (y/N)"); - ncurses::doupdate(); - ch = ncurses::getch(); - } else { - ch = 'y' as i32; - } - if ch == 'y' as i32 { - Self::remove_files(&paths)?; - ui::wprint_msg(&view.bot_win, "Deleted files"); - ReloadDirList::reload(context.curr_tab_index, context)?; - } + let paths = curr_tab.curr_list.get_selected_paths(); + if paths.is_empty() { + return Err(std::io::Error::new( + std::io::ErrorKind::Other, + "no files selected", + )); + } + if paths.len() > 1 { + ui::wprint_msg(&view.bot_win, "Are you sure? (y/N)"); + } else { } + Self::remove_files(&paths)?; + ui::wprint_msg(&view.bot_win, "Deleted files"); + ReloadDirList::reload(context.curr_tab_index, context)?; Ok(()) } } |