diff options
author | Jiayi Zhao <jeff.no.zhao@gmail.com> | 2020-02-10 22:09:58 -0500 |
---|---|---|
committer | Jiayi Zhao <jeff.no.zhao@gmail.com> | 2020-02-11 09:33:06 -0500 |
commit | daf9d7b9afec8c598c0974c5d92263c3af5facf0 (patch) | |
tree | 5273968eb2b2ffc412ebe1894a96d13c9ae57d09 /src/commands/parent_directory.rs | |
parent | b09ecb650aa5805c7021ab76672dddc0a7b0bb52 (diff) |
progress on switching to tui-rs for ui
Diffstat (limited to 'src/commands/parent_directory.rs')
-rw-r--r-- | src/commands/parent_directory.rs | 20 |
1 files changed, 4 insertions, 16 deletions
diff --git a/src/commands/parent_directory.rs b/src/commands/parent_directory.rs index e514f94..ee3c621 100644 --- a/src/commands/parent_directory.rs +++ b/src/commands/parent_directory.rs @@ -2,7 +2,7 @@ use crate::commands::{JoshutoCommand, JoshutoRunnable}; use crate::context::JoshutoContext; use crate::error::JoshutoResult; use crate::history::DirectoryHistory; -use crate::window::JoshutoView; +use crate::ui::TuiBackend; #[derive(Clone, Debug)] pub struct ParentDirectory; @@ -17,25 +17,13 @@ impl ParentDirectory { pub fn parent_directory( context: &mut JoshutoContext, - view: &JoshutoView, + backend: &mut TuiBackend, ) -> std::io::Result<()> { let curr_tab = &mut context.tabs[context.curr_tab_index]; if !curr_tab.curr_path.pop() { return Ok(()); } std::env::set_current_dir(&curr_tab.curr_path)?; - - let mut new_curr_list = curr_tab - .history - .pop_or_create(&curr_tab.curr_path, &context.config_t.sort_option)?; - - std::mem::swap(&mut curr_tab.curr_list, &mut new_curr_list); - curr_tab - .history - .insert(new_curr_list.file_path().clone(), new_curr_list); - - curr_tab.refresh(view, &context.config_t); - ncurses::doupdate(); Ok(()) } } @@ -49,8 +37,8 @@ impl std::fmt::Display for ParentDirectory { } impl JoshutoRunnable for ParentDirectory { - fn execute(&self, context: &mut JoshutoContext, view: &JoshutoView) -> JoshutoResult<()> { - Self::parent_directory(context, view)?; + fn execute(&self, context: &mut JoshutoContext, backend: &mut TuiBackend) -> JoshutoResult<()> { + Self::parent_directory(context, backend)?; Ok(()) } } |