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/new_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/new_directory.rs')
-rw-r--r-- | src/commands/new_directory.rs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/commands/new_directory.rs b/src/commands/new_directory.rs index 788d576..243cf6a 100644 --- a/src/commands/new_directory.rs +++ b/src/commands/new_directory.rs @@ -4,6 +4,7 @@ use crate::commands::{JoshutoCommand, JoshutoRunnable, ReloadDirList}; use crate::context::JoshutoContext; use crate::textfield::JoshutoTextField; use crate::ui; +use crate::window::JoshutoView; #[derive(Clone, Debug)] pub struct NewDirectory; @@ -26,7 +27,7 @@ impl std::fmt::Display for NewDirectory { } impl JoshutoRunnable for NewDirectory { - fn execute(&self, context: &mut JoshutoContext) { + fn execute(&self, context: &mut JoshutoContext, view: &JoshutoView) { let (term_rows, term_cols) = ui::getmaxyx(); const PROMPT: &str = ":mkdir "; @@ -47,10 +48,10 @@ impl JoshutoRunnable for NewDirectory { match std::fs::create_dir_all(&path) { Ok(_) => { - ReloadDirList::reload(context); + ReloadDirList::reload(context, view); } 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()); } } } |