summaryrefslogtreecommitdiffstats
path: root/src/commands/delete_files.rs
diff options
context:
space:
mode:
authorJiayi Zhao <jeff.no.zhao@gmail.com>2019-03-30 15:11:08 -0400
committerJiayi Zhao <jeff.no.zhao@gmail.com>2019-03-30 15:11:08 -0400
commit554f06d72aeb639548314336b2318e14f8ffcc7e (patch)
tree4f3346fdd7b9302ccaa82089cd7eceff4d8b28de /src/commands/delete_files.rs
parentf56511becd2be285ff2ce74269113384856aaa95 (diff)
move view struct out of Context and pass in as a separate argument
- rename static variables to all caps - change index to be Option<usize> rather than i32 where -1 means the directory is empty
Diffstat (limited to 'src/commands/delete_files.rs')
-rw-r--r--src/commands/delete_files.rs17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/commands/delete_files.rs b/src/commands/delete_files.rs
index 9a3caed..1875b39 100644
--- a/src/commands/delete_files.rs
+++ b/src/commands/delete_files.rs
@@ -6,6 +6,7 @@ use crate::config::keymap;
use crate::context::JoshutoContext;
use crate::preview;
use crate::ui;
+use crate::window::JoshutoView;
#[derive(Clone, Debug)]
pub struct DeleteFiles;
@@ -41,8 +42,8 @@ impl std::fmt::Display for DeleteFiles {
}
impl JoshutoRunnable for DeleteFiles {
- fn execute(&self, context: &mut JoshutoContext) {
- ui::wprint_msg(&context.views.bot_win, "Delete selected files? (Y/n)");
+ fn execute(&self, context: &mut JoshutoContext, view: &JoshutoView) {
+ ui::wprint_msg(&view.bot_win, "Delete selected files? (Y/n)");
ncurses::timeout(-1);
ncurses::doupdate();
@@ -51,9 +52,9 @@ impl JoshutoRunnable for DeleteFiles {
if let Some(s) = context.tabs[context.curr_tab_index].curr_list.as_ref() {
if let Some(paths) = commands::collect_selected_paths(s) {
match Self::remove_files(paths) {
- Ok(_) => ui::wprint_msg(&context.views.bot_win, "Deleted files"),
+ Ok(_) => ui::wprint_msg(&view.bot_win, "Deleted files"),
Err(e) => {
- ui::wprint_err(&context.views.bot_win, e.to_string().as_str());
+ ui::wprint_err(&view.bot_win, e.to_string().as_str());
ncurses::doupdate();
return;
}
@@ -64,23 +65,23 @@ impl JoshutoRunnable for DeleteFiles {
let curr_tab = &mut context.tabs[context.curr_tab_index];
curr_tab.reload_contents(&context.config_t.sort_type);
curr_tab.refresh(
- &context.views,
+ &view,
&context.config_t,
&context.username,
&context.hostname,
);
} else {
let curr_tab = &context.tabs[context.curr_tab_index];
- curr_tab.refresh_file_status(&context.views.bot_win);
+ curr_tab.refresh_file_status(&view.bot_win);
curr_tab.refresh_path_status(
- &context.views.top_win,
+ &view.top_win,
&context.username,
&context.hostname,
context.config_t.tilde_in_titlebar,
);
}
let curr_tab = &mut context.tabs[context.curr_tab_index];
- preview::preview_file(curr_tab, &context.views, &context.config_t);
+ preview::preview_file(curr_tab, &view, &context.config_t);
ncurses::doupdate();
}
}