summaryrefslogtreecommitdiffstats
path: root/src/commands
diff options
context:
space:
mode:
authorJeff Zhao <jeff.no.zhao@gmail.com>2021-06-21 19:44:17 -0400
committerGitHub <noreply@github.com>2021-06-21 19:44:17 -0400
commit34538845ba899a6892c6bbc10d294f209b78fdd7 (patch)
tree167474092e146951da856a995088aaf730a85c7d /src/commands
parentcf660136ea43e0a463fd270bfdaf8bb3ee606d9d (diff)
fix file sizes not appearing when filename too long (#78)
* fix file sizes not appearing when filename too long * refactor previewing code - event.rs is moved out of utils as its an integral part of the codebase - load_child.rs has been replaced with preview module - moved previewing logic inside run.rs instead of spreading it across multiple commands * revert tui_dirlist_detailed to use MIN_LEFT_LABEL_WIDTH - add previewing loading trigger to mouse input as well * fix: right label disappears (#79) Co-authored-by: DLFW <daniel@llin.info>
Diffstat (limited to 'src/commands')
-rw-r--r--src/commands/change_directory.rs2
-rw-r--r--src/commands/cursor_move.rs14
-rw-r--r--src/commands/delete_files.rs2
-rw-r--r--src/commands/key_command.rs2
-rw-r--r--src/commands/new_directory.rs2
-rw-r--r--src/commands/open_file.rs2
-rw-r--r--src/commands/parent_directory.rs2
-rw-r--r--src/commands/reload.rs2
-rw-r--r--src/commands/rename_file.rs2
-rw-r--r--src/commands/sort.rs12
-rw-r--r--src/commands/tab_ops.rs2
-rw-r--r--src/commands/touch_file.rs9
12 files changed, 10 insertions, 43 deletions
diff --git a/src/commands/change_directory.rs b/src/commands/change_directory.rs
index 561aea4..0499011 100644
--- a/src/commands/change_directory.rs
+++ b/src/commands/change_directory.rs
@@ -3,7 +3,6 @@ use std::path;
use crate::context::AppContext;
use crate::error::JoshutoResult;
use crate::history::DirectoryHistory;
-use crate::util::load_child::LoadChild;
pub fn cd(path: &path::Path, context: &mut AppContext) -> std::io::Result<()> {
std::env::set_current_dir(path)?;
@@ -25,6 +24,5 @@ fn _change_directory(path: &path::Path, context: &mut AppContext) -> std::io::Re
pub fn change_directory(context: &mut AppContext, path: &path::Path) -> JoshutoResult<()> {
_change_directory(path, context)?;
- LoadChild::load_child(context)?;
Ok(())
}
diff --git a/src/commands/cursor_move.rs b/src/commands/cursor_move.rs
index c17097b..92042d6 100644
--- a/src/commands/cursor_move.rs
+++ b/src/commands/cursor_move.rs
@@ -1,7 +1,7 @@
use crate::context::AppContext;
use crate::error::JoshutoResult;
-use crate::history::DirectoryHistory;
use crate::ui::TuiBackend;
+
use std::path::PathBuf;
pub fn cursor_move(new_index: usize, context: &mut AppContext) -> JoshutoResult<()> {
@@ -20,18 +20,6 @@ pub fn cursor_move(new_index: usize, context: &mut AppContext) -> JoshutoResult<
path = Some(entry.file_path().to_path_buf())
}
}
-
- // get preview
- if let Some(path) = path {
- if path.is_dir() {
- let options = context.config_ref().display_options_ref().clone();
- context
- .tab_context_mut()
- .curr_tab_mut()
- .history_mut()
- .create_or_soft_update(path.as_path(), &options)?;
- }
- }
Ok(())
}
diff --git a/src/commands/delete_files.rs b/src/commands/delete_files.rs
index ba84b33..4339a39 100644
--- a/src/commands/delete_files.rs
+++ b/src/commands/delete_files.rs
@@ -7,7 +7,6 @@ use crate::context::AppContext;
use crate::history::DirectoryHistory;
use crate::ui::widgets::TuiPrompt;
use crate::ui::TuiBackend;
-use crate::util::load_child::LoadChild;
use super::reload;
@@ -116,6 +115,5 @@ pub fn delete_selected_files(
for tab in context.tab_context_mut().iter_mut() {
tab.history_mut().reload(&curr_path, &options)?;
}
- LoadChild::load_child(context)?;
Ok(())
}
diff --git a/src/commands/key_command.rs b/src/commands/key_command.rs
index d4f94be..3ca2980 100644
--- a/src/commands/key_command.rs
+++ b/src/commands/key_command.rs
@@ -4,7 +4,6 @@ use crate::context::AppContext;
use crate::error::{JoshutoError, JoshutoErrorKind, JoshutoResult};
use crate::io::IoWorkerOptions;
use crate::ui::TuiBackend;
-use crate::util::load_child::LoadChild;
use crate::util::select::SelectOption;
use crate::util::sort::SortType;
@@ -358,7 +357,6 @@ impl AppExecute for KeyCommand {
Self::BulkRename => bulk_rename::bulk_rename(context, backend),
Self::ChangeDirectory(p) => {
change_directory::change_directory(context, p.as_path())?;
- LoadChild::load_child(context)?;
Ok(())
}
Self::NewTab => tab_ops::new_tab(context),
diff --git a/src/commands/new_directory.rs b/src/commands/new_directory.rs
index 6b0f3d0..8364d93 100644
--- a/src/commands/new_directory.rs
+++ b/src/commands/new_directory.rs
@@ -3,7 +3,6 @@ use std::path;
use crate::context::AppContext;
use crate::error::JoshutoResult;
use crate::history::DirectoryHistory;
-use crate::util::load_child::LoadChild;
pub fn new_directory(context: &mut AppContext, p: &path::Path) -> JoshutoResult<()> {
std::fs::create_dir_all(p)?;
@@ -12,6 +11,5 @@ pub fn new_directory(context: &mut AppContext, p: &path::Path) -> JoshutoResult<
for tab in context.tab_context_mut().iter_mut() {
tab.history_mut().reload(&curr_path, &options)?;
}
- LoadChild::load_child(context)?;
Ok(())
}
diff --git a/src/commands/open_file.rs b/src/commands/open_file.rs
index ca07abc..e1d4208 100644
--- a/src/commands/open_file.rs
+++ b/src/commands/open_file.rs
@@ -6,7 +6,6 @@ use crate::context::AppContext;
use crate::error::{JoshutoError, JoshutoErrorKind, JoshutoResult};
use crate::ui::views::TuiTextField;
use crate::ui::TuiBackend;
-use crate::util::load_child::LoadChild;
use super::change_directory;
@@ -35,7 +34,6 @@ pub fn open(context: &mut AppContext, backend: &mut TuiBackend) -> JoshutoResult
if entry.file_path().is_dir() {
let path = entry.file_path().to_path_buf();
change_directory::cd(path.as_path(), context)?;
- LoadChild::load_child(context)?;
} else {
let paths = context
.tab_context_ref()
diff --git a/src/commands/parent_directory.rs b/src/commands/parent_directory.rs
index 198841b..0b3a0b7 100644
--- a/src/commands/parent_directory.rs
+++ b/src/commands/parent_directory.rs
@@ -1,6 +1,5 @@
use crate::context::AppContext;
use crate::error::JoshutoResult;
-use crate::util::load_child::LoadChild;
use super::reload;
@@ -24,6 +23,5 @@ pub fn parent_directory_helper(context: &mut AppContext) -> std::io::Result<()>
pub fn parent_directory(context: &mut AppContext) -> JoshutoResult<()> {
parent_directory_helper(context)?;
reload::soft_reload(context.tab_context_ref().index, context)?;
- LoadChild::load_child(context)?;
Ok(())
}
diff --git a/src/commands/reload.rs b/src/commands/reload.rs
index 1c149ce..de33a4f 100644
--- a/src/commands/reload.rs
+++ b/src/commands/reload.rs
@@ -1,6 +1,5 @@
use crate::context::AppContext;
use crate::error::JoshutoResult;
-use crate::util::load_child::LoadChild;
pub fn soft_reload(index: usize, context: &mut AppContext) -> std::io::Result<()> {
let options = context.config_ref().display_options_ref().clone();
@@ -42,6 +41,5 @@ pub fn reload(context: &mut AppContext, index: usize) -> std::io::Result<()> {
pub fn reload_dirlist(context: &mut AppContext) -> JoshutoResult<()> {
reload(context, context.tab_context_ref().index)?;
- LoadChild::load_child(context)?;
Ok(())
}
diff --git a/src/commands/rename_file.rs b/src/commands/rename_file.rs
index 011ee50..6907445 100644
--- a/src/commands/rename_file.rs
+++ b/src/commands/rename_file.rs
@@ -3,7 +3,6 @@ use std::path;
use crate::context::AppContext;
use crate::error::JoshutoResult;
use crate::ui::TuiBackend;
-use crate::util::load_child::LoadChild;
use super::command_line;
@@ -36,7 +35,6 @@ pub fn rename_file(context: &mut AppContext, dest: &path::Path) -> JoshutoResult
if let Some(path) = path {
_rename_file(context, path.as_path(), dest)?;
}
- LoadChild::load_child(context)?;
Ok(())
}
diff --git a/src/commands/sort.rs b/src/commands/sort.rs
index 58ffd2e..dfc86a2 100644
--- a/src/commands/sort.rs
+++ b/src/commands/sort.rs
@@ -1,8 +1,6 @@
use crate::context::AppContext;
use crate::error::JoshutoResult;
use crate::history::DirectoryHistory;
-
-use crate::util::load_child::LoadChild;
use crate::util::sort::SortType;
use super::reload;
@@ -15,10 +13,7 @@ pub fn set_sort(context: &mut AppContext, method: SortType) -> JoshutoResult<()>
for tab in context.tab_context_mut().iter_mut() {
tab.history_mut().depreciate_all_entries();
}
-
- reload::soft_reload(context.tab_context_ref().index, context)?;
- LoadChild::load_child(context)?;
- Ok(())
+ refresh(context)
}
pub fn toggle_reverse(context: &mut AppContext) -> JoshutoResult<()> {
@@ -28,7 +23,10 @@ pub fn toggle_reverse(context: &mut AppContext) -> JoshutoResult<()> {
for tab in context.tab_context_mut().iter_mut() {
tab.history_mut().depreciate_all_entries();
}
+ refresh(context)
+}
+
+fn refresh(context: &mut AppContext) -> JoshutoResult<()> {
reload::soft_reload(context.tab_context_ref().index, context)?;
- LoadChild::load_child(context)?;
Ok(())
}
diff --git a/src/commands/tab_ops.rs b/src/commands/tab_ops.rs
index f777df4..d3883af 100644
--- a/src/commands/tab_ops.rs
+++ b/src/commands/tab_ops.rs
@@ -4,7 +4,6 @@ use crate::context::AppContext;
use crate::error::JoshutoResult;
use crate::history::DirectoryHistory;
use crate::tab::{JoshutoTab, TabHomePage};
-use crate::util::load_child::LoadChild;
use crate::HOME_DIR;
@@ -70,7 +69,6 @@ pub fn new_tab(context: &mut AppContext) -> JoshutoResult<()> {
let new_index = context.tab_context_ref().len() - 1;
context.tab_context_mut().index = new_index;
_tab_switch(new_index, context)?;
- LoadChild::load_child(context)?;
Ok(())
}
diff --git a/src/commands/touch_file.rs b/src/commands/touch_file.rs
index dff1666..458aad4 100644
--- a/src/commands/touch_file.rs
+++ b/src/commands/touch_file.rs
@@ -1,11 +1,11 @@
+use std::fs::File;
use std::path;
+use std::time::SystemTime;
+
+use filetime::FileTime;
use crate::context::AppContext;
use crate::error::JoshutoResult;
-use crate::util::load_child::LoadChild;
-use filetime::FileTime;
-use std::fs::File;
-use std::time::SystemTime;
fn _update_actime(file: &path::Path) -> std::io::Result<()> {
let file_time = FileTime::from_system_time(SystemTime::now());
@@ -44,6 +44,5 @@ pub fn touch_file(context: &mut AppContext, arg: &str) -> JoshutoResult<()> {
if let Some(curr_list) = context.tab_context_mut().curr_tab_mut().curr_list_mut() {
curr_list.reload_contents(&options)?;
}
- LoadChild::load_child(context)?;
Ok(())
}