From 12eb9eed1aeb4f3045b78dd19ae20d07bfea7de9 Mon Sep 17 00:00:00 2001 From: Jiayi Zhao Date: Tue, 15 Dec 2020 11:48:20 -0500 Subject: add option to not collapse preview - add methods to access config_t - add back home dir path shortening option --- src/commands/change_directory.rs | 2 +- src/commands/cursor_move.rs | 2 +- src/commands/delete_files.rs | 2 +- src/commands/new_directory.rs | 2 +- src/commands/parent_cursor_move.rs | 2 +- src/commands/reload.rs | 4 ++-- src/commands/rename_file.rs | 2 +- src/commands/show_hidden.rs | 4 ++-- src/commands/sort.rs | 4 ++-- src/commands/tab_ops.rs | 4 ++-- 10 files changed, 14 insertions(+), 14 deletions(-) (limited to 'src/commands') diff --git a/src/commands/change_directory.rs b/src/commands/change_directory.rs index 1094111..e1c1167 100644 --- a/src/commands/change_directory.rs +++ b/src/commands/change_directory.rs @@ -13,7 +13,7 @@ pub fn cd(path: &path::Path, context: &mut JoshutoContext) -> std::io::Result<() pub fn change_directories(path: &path::Path, context: &mut JoshutoContext) -> std::io::Result<()> { cd(path, context)?; - let sort_options = context.config_t.sort_option.clone(); + let sort_options = context.config_ref().sort_option.clone(); context .tab_context_mut() .curr_tab_mut() diff --git a/src/commands/cursor_move.rs b/src/commands/cursor_move.rs index bad885f..3b9aeda 100644 --- a/src/commands/cursor_move.rs +++ b/src/commands/cursor_move.rs @@ -24,7 +24,7 @@ pub fn cursor_move(new_index: usize, context: &mut JoshutoContext) -> JoshutoRes // get preview if let Some(path) = path { if path.is_dir() { - let sort_options = context.config_t.sort_option.clone(); + let sort_options = context.config_ref().sort_option.clone(); context .tab_context_mut() .curr_tab_mut() diff --git a/src/commands/delete_files.rs b/src/commands/delete_files.rs index bc070f1..ed73e18 100644 --- a/src/commands/delete_files.rs +++ b/src/commands/delete_files.rs @@ -77,7 +77,7 @@ pub fn delete_selected_files( ) -> std::io::Result<()> { delete_files(context, backend)?; - let options = context.config_t.sort_option.clone(); + let options = context.config_ref().sort_option.clone(); let curr_path = context.tab_context_ref().curr_tab_ref().pwd().to_path_buf(); for tab in context.tab_context_mut().iter_mut() { tab.history_mut().reload(&curr_path, &options)?; diff --git a/src/commands/new_directory.rs b/src/commands/new_directory.rs index 2c5fd57..6b17817 100644 --- a/src/commands/new_directory.rs +++ b/src/commands/new_directory.rs @@ -7,7 +7,7 @@ use crate::util::load_child::LoadChild; pub fn new_directory(context: &mut JoshutoContext, p: &path::Path) -> JoshutoResult<()> { std::fs::create_dir_all(p)?; - let options = context.config_t.sort_option.clone(); + let options = context.config_ref().sort_option.clone(); let curr_path = context.tab_context_ref().curr_tab_ref().pwd().to_path_buf(); for tab in context.tab_context_mut().iter_mut() { tab.history_mut().reload(&curr_path, &options)?; diff --git a/src/commands/parent_cursor_move.rs b/src/commands/parent_cursor_move.rs index 87f6d11..9656ad8 100644 --- a/src/commands/parent_cursor_move.rs +++ b/src/commands/parent_cursor_move.rs @@ -30,7 +30,7 @@ pub fn parent_cursor_move(new_index: usize, context: &mut JoshutoContext) -> Jos // get preview if let Some(path) = path { if path.is_dir() { - let sort_options = context.config_t.sort_option.clone(); + let sort_options = context.config_ref().sort_option.clone(); context .tab_context_mut() .curr_tab_mut() diff --git a/src/commands/reload.rs b/src/commands/reload.rs index b05d538..fbd17ec 100644 --- a/src/commands/reload.rs +++ b/src/commands/reload.rs @@ -3,7 +3,7 @@ use crate::error::JoshutoResult; use crate::util::load_child::LoadChild; pub fn soft_reload(index: usize, context: &mut JoshutoContext) -> std::io::Result<()> { - let sort_option = context.config_t.sort_option.clone(); + let sort_option = context.config_ref().sort_option.clone(); if let Some(curr_tab) = context.tab_context_mut().tab_mut(index) { if let Some(curr_list) = curr_tab.curr_list_mut() { if curr_list.need_update() { @@ -25,7 +25,7 @@ pub fn soft_reload(index: usize, context: &mut JoshutoContext) -> std::io::Resul } pub fn reload(context: &mut JoshutoContext, index: usize) -> std::io::Result<()> { - let sort_option = context.config_t.sort_option.clone(); + let sort_option = context.config_ref().sort_option.clone(); if let Some(curr_tab) = context.tab_context_mut().tab_mut(index) { if let Some(curr_list) = curr_tab.curr_list_mut() { curr_list.reload_contents(&sort_option)?; diff --git a/src/commands/rename_file.rs b/src/commands/rename_file.rs index 593df97..790068b 100644 --- a/src/commands/rename_file.rs +++ b/src/commands/rename_file.rs @@ -18,7 +18,7 @@ pub fn _rename_file( return Err(err); } std::fs::rename(&src, &dest)?; - let options = context.config_t.sort_option.clone(); + let options = context.config_ref().sort_option.clone(); if let Some(curr_list) = context.tab_context_mut().curr_tab_mut().curr_list_mut() { curr_list.reload_contents(&options)?; } diff --git a/src/commands/show_hidden.rs b/src/commands/show_hidden.rs index aabc000..f2c9c02 100644 --- a/src/commands/show_hidden.rs +++ b/src/commands/show_hidden.rs @@ -5,8 +5,8 @@ use crate::history::DirectoryHistory; use super::reload; pub fn _toggle_hidden(context: &mut JoshutoContext) { - let opposite = !context.config_t.sort_option.show_hidden; - context.config_t.sort_option.show_hidden = opposite; + let opposite = !context.config_ref().sort_option.show_hidden; + context.config_mut().sort_option.show_hidden = opposite; for tab in context.tab_context_mut().iter_mut() { tab.history_mut().depreciate_all_entries(); diff --git a/src/commands/sort.rs b/src/commands/sort.rs index e44280e..dff0fd3 100644 --- a/src/commands/sort.rs +++ b/src/commands/sort.rs @@ -8,7 +8,7 @@ use crate::util::sort::SortType; use super::reload; pub fn set_sort(context: &mut JoshutoContext, method: SortType) -> JoshutoResult<()> { - context.config_t.sort_option.sort_method = method; + context.config_mut().sort_option.sort_method = method; for tab in context.tab_context_mut().iter_mut() { tab.history_mut().depreciate_all_entries(); } @@ -18,7 +18,7 @@ pub fn set_sort(context: &mut JoshutoContext, method: SortType) -> JoshutoResult } pub fn toggle_reverse(context: &mut JoshutoContext) -> JoshutoResult<()> { - context.config_t.sort_option.reverse = !context.config_t.sort_option.reverse; + context.config_mut().sort_option.reverse = !context.config_ref().sort_option.reverse; for tab in context.tab_context_mut().iter_mut() { tab.history_mut().depreciate_all_entries(); } diff --git a/src/commands/tab_ops.rs b/src/commands/tab_ops.rs index a5789cf..a1815a4 100644 --- a/src/commands/tab_ops.rs +++ b/src/commands/tab_ops.rs @@ -15,7 +15,7 @@ fn _tab_switch(new_index: usize, context: &mut JoshutoContext) -> std::io::Resul let path = context.tab_context_ref().curr_tab_ref().pwd().to_path_buf(); std::env::set_current_dir(path.as_path())?; - let options = context.config_t.sort_option.clone(); + let options = context.config_ref().sort_option.clone(); context .tab_context_mut() .curr_tab_mut() @@ -39,7 +39,7 @@ pub fn new_tab(context: &mut JoshutoContext) -> JoshutoResult<()> { None => path::PathBuf::from("/"), }; - let tab = JoshutoTab::new(curr_path, &context.config_t.sort_option)?; + let tab = JoshutoTab::new(curr_path, &context.config_ref().sort_option)?; context.tab_context_mut().push_tab(tab); let new_index = context.tab_context_ref().len() - 1; context.tab_context_mut().set_index(new_index); -- cgit v1.2.3