diff options
author | Jiayi Zhao <jeff.no.zhao@gmail.com> | 2019-05-05 20:11:36 -0400 |
---|---|---|
committer | Jiayi Zhao <jeff.no.zhao@gmail.com> | 2019-05-05 20:11:36 -0400 |
commit | 4c194de5c7e940e1eaf71c0fb4b455ba6547c880 (patch) | |
tree | 331eb9908c67fe9a2f6d6e98e3b2d4f0901326bc /src/commands/delete_files.rs | |
parent | 6b013bb91969d7e269aa5a08da729a8370a31900 (diff) |
use readline() instead of readline_with_initial with possible
Diffstat (limited to 'src/commands/delete_files.rs')
-rw-r--r-- | src/commands/delete_files.rs | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/src/commands/delete_files.rs b/src/commands/delete_files.rs index 283a1d3..615f12d 100644 --- a/src/commands/delete_files.rs +++ b/src/commands/delete_files.rs @@ -41,24 +41,28 @@ impl DeleteFiles { ncurses::doupdate(); let curr_tab = &mut context.tabs[context.curr_tab_index]; - let ch = ncurses::getch(); + let mut ch = ncurses::getch(); if ch == 'y' as i32 || ch == keymap::ENTER as i32 { - ui::wprint_msg(&view.bot_win, "Are you sure? (Y/n)"); - ncurses::doupdate(); - let ch = ncurses::getch(); - if ch == 'y' as i32 || ch == keymap::ENTER as i32 { - if let Some(paths) = curr_tab.curr_list.get_selected_paths() { + if let Some(paths) = curr_tab.curr_list.get_selected_paths() { + 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"); - } - curr_tab.reload_contents(&context.config_t.sort_option)?; - curr_tab.refresh( - &view, - &context.config_t, - &context.username, - &context.hostname, - ); + curr_tab.reload_contents(&context.config_t.sort_option)?; + curr_tab.refresh( + &view, + &context.config_t, + &context.username, + &context.hostname, + ); + } } else { curr_tab.refresh_file_status(&view.bot_win); curr_tab.refresh_path_status( |