diff options
author | Jeff Zhao <jeff.no.zhao@gmail.com> | 2022-08-30 13:46:49 -0400 |
---|---|---|
committer | Jeff Zhao <jeff.no.zhao@gmail.com> | 2022-08-30 13:46:49 -0400 |
commit | cd838711107303e4c6076df5bc38b2b74c819480 (patch) | |
tree | 3608d15a9e48f21b9ad833960e500e6d13a267f8 /src/commands | |
parent | 9f5e6e0dbf239cdb08a7974147d0fa3f8183e364 (diff) | |
parent | 826e24eaf4a10921bdd087079c4d7330896b79c2 (diff) |
Merge branch 'main' of github.com:kamiyaa/joshuto
Diffstat (limited to 'src/commands')
-rw-r--r-- | src/commands/escape.rs | 9 | ||||
-rw-r--r-- | src/commands/flat.rs | 9 | ||||
-rw-r--r-- | src/commands/mod.rs | 2 | ||||
-rw-r--r-- | src/commands/quit.rs | 2 | ||||
-rw-r--r-- | src/commands/select.rs | 18 | ||||
-rw-r--r-- | src/commands/uimodes.rs | 9 |
6 files changed, 38 insertions, 11 deletions
diff --git a/src/commands/escape.rs b/src/commands/escape.rs new file mode 100644 index 0000000..1a507df --- /dev/null +++ b/src/commands/escape.rs @@ -0,0 +1,9 @@ +use crate::context::AppContext; +use crate::error::JoshutoResult; + +pub fn escape(context: &mut AppContext) -> JoshutoResult { + if let Some(curr_dir_list) = context.tab_context_mut().curr_tab_mut().curr_list_mut() { + curr_dir_list.visual_mode_cancel(); + }; + Ok(()) +} diff --git a/src/commands/flat.rs b/src/commands/flat.rs index c0e9dfb..b9d0a64 100644 --- a/src/commands/flat.rs +++ b/src/commands/flat.rs @@ -79,7 +79,14 @@ pub fn flatten(depth: usize, context: &mut AppContext) -> JoshutoResult { contents.sort_by(|f1, f2| sort_options.compare(f1, f2)); let metadata = JoshutoMetadata::from(path.as_path())?; - let dirlist = JoshutoDirList::new(path.clone(), contents, index, viewport_index, metadata); + let dirlist = JoshutoDirList::new( + path.clone(), + contents, + index, + viewport_index, + None, + metadata, + ); history.insert(path, dirlist); Ok(()) diff --git a/src/commands/mod.rs b/src/commands/mod.rs index 4f270ea..0bf83ae 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -3,6 +3,7 @@ pub mod change_directory; pub mod command_line; pub mod cursor_move; pub mod delete_files; +pub mod escape; pub mod file_ops; pub mod flat; pub mod line_nums; @@ -28,4 +29,5 @@ pub mod sub_process; pub mod subdir_fzf; pub mod tab_ops; pub mod touch_file; +pub mod uimodes; pub mod zoxide; diff --git a/src/commands/quit.rs b/src/commands/quit.rs index ccc9a8b..165f289 100644 --- a/src/commands/quit.rs +++ b/src/commands/quit.rs @@ -3,7 +3,7 @@ use std::io; use crate::context::AppContext; use crate::error::{JoshutoError, JoshutoErrorKind, JoshutoResult}; -#[derive(Clone, Copy, Debug, PartialEq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum QuitAction { DoNot, Noop, diff --git a/src/commands/select.rs b/src/commands/select.rs index a4d26c4..3bfa227 100644 --- a/src/commands/select.rs +++ b/src/commands/select.rs @@ -23,11 +23,11 @@ fn select_without_pattern(context: &mut AppContext, options: &SelectOption) -> J if let Some(curr_list) = context.tab_context_mut().curr_tab_mut().curr_list_mut() { curr_list.iter_mut().for_each(|e| { if options.reverse { - e.set_selected(false); + e.set_permanent_selected(false); } else if options.toggle { - e.set_selected(!e.is_selected()); + e.set_permanent_selected(!e.is_selected()); } else { - e.set_selected(true); + e.set_permanent_selected(true); } }); } @@ -38,11 +38,11 @@ fn select_without_pattern(context: &mut AppContext, options: &SelectOption) -> J .and_then(|s| s.curr_entry_mut()) { if options.reverse { - entry.set_selected(false); + entry.set_permanent_selected(false); } else if options.toggle { - entry.set_selected(!entry.is_selected()); + entry.set_permanent_selected(!entry.is_selected()); } else { - entry.set_selected(true); + entry.set_permanent_selected(true); } cursor_move::down(context, 1)?; } @@ -64,11 +64,11 @@ fn select_with_pattern( .for_each(|e| { found += 1; if options.reverse { - e.set_selected(false); + e.set_permanent_selected(false); } else if options.toggle { - e.set_selected(!e.is_selected()); + e.set_permanent_selected(!e.is_selected()); } else { - e.set_selected(true); + e.set_permanent_selected(true); } }); context diff --git a/src/commands/uimodes.rs b/src/commands/uimodes.rs new file mode 100644 index 0000000..480cc75 --- /dev/null +++ b/src/commands/uimodes.rs @@ -0,0 +1,9 @@ +use crate::context::AppContext; +use crate::error::JoshutoResult; + +pub fn toggle_visual_mode(context: &mut AppContext) -> JoshutoResult { + if let Some(curr_dir_list) = context.tab_context_mut().curr_tab_mut().curr_list_mut() { + curr_dir_list.toggle_visual_mode() + }; + Ok(()) +} |