diff options
author | Jiayi Zhao <jeff.no.zhao@gmail.com> | 2019-03-30 15:11:08 -0400 |
---|---|---|
committer | Jiayi Zhao <jeff.no.zhao@gmail.com> | 2019-03-30 15:11:08 -0400 |
commit | 554f06d72aeb639548314336b2318e14f8ffcc7e (patch) | |
tree | 4f3346fdd7b9302ccaa82089cd7eceff4d8b28de /src/commands/parent_directory.rs | |
parent | f56511becd2be285ff2ce74269113384856aaa95 (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/parent_directory.rs')
-rw-r--r-- | src/commands/parent_directory.rs | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/commands/parent_directory.rs b/src/commands/parent_directory.rs index 7dc2f1e..4542af7 100644 --- a/src/commands/parent_directory.rs +++ b/src/commands/parent_directory.rs @@ -2,6 +2,7 @@ use crate::commands::{JoshutoCommand, JoshutoRunnable}; use crate::context::JoshutoContext; use crate::preview; use crate::ui; +use crate::window::JoshutoView; #[derive(Clone, Debug)] pub struct ParentDirectory; @@ -14,7 +15,7 @@ impl ParentDirectory { "parent_directory" } - pub fn parent_directory(context: &mut JoshutoContext) { + pub fn parent_directory(context: &mut JoshutoContext, view: &JoshutoView) { if !context.curr_tab_mut().curr_path.pop() { return; } @@ -36,26 +37,26 @@ impl ParentDirectory { { Ok(s) => Some(s), Err(e) => { - ui::wprint_err(&context.views.left_win, e.to_string().as_str()); + ui::wprint_err(&view.left_win, e.to_string().as_str()); None } }; } None => { - ncurses::werase(context.views.left_win.win); - ncurses::wnoutrefresh(context.views.left_win.win); + ncurses::werase(view.left_win.win); + view.left_win.queue_for_refresh(); } } curr_tab.refresh( - &context.views, + view, &context.config_t, &context.username, &context.hostname, ); - preview::preview_file(curr_tab, &context.views, &context.config_t); + preview::preview_file(curr_tab, view, &context.config_t); } 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(); @@ -71,7 +72,7 @@ impl std::fmt::Display for ParentDirectory { } impl JoshutoRunnable for ParentDirectory { - fn execute(&self, context: &mut JoshutoContext) { - Self::parent_directory(context); + fn execute(&self, context: &mut JoshutoContext, view: &JoshutoView) { + Self::parent_directory(context, view); } } |