diff options
Diffstat (limited to 'src/key_command')
-rw-r--r-- | src/key_command/command.rs | 4 | ||||
-rw-r--r-- | src/key_command/constants.rs | 1 | ||||
-rw-r--r-- | src/key_command/impl_appcommand.rs | 1 | ||||
-rw-r--r-- | src/key_command/impl_appexecute.rs | 1 | ||||
-rw-r--r-- | src/key_command/impl_comment.rs | 7 | ||||
-rw-r--r-- | src/key_command/impl_from_str.rs | 4 |
6 files changed, 15 insertions, 3 deletions
diff --git a/src/key_command/command.rs b/src/key_command/command.rs index bc8fe6d..5da7e27 100644 --- a/src/key_command/command.rs +++ b/src/key_command/command.rs @@ -1,7 +1,7 @@ use std::path; use crate::commands::quit::QuitAction; -use crate::config::option::{LineNumberStyle, SelectOption, SortType}; +use crate::config::option::{LineMode, LineNumberStyle, SelectOption, SortType}; use crate::io::FileOperationOptions; #[derive(Clone, Debug)] @@ -53,6 +53,8 @@ pub enum Command { CursorMovePageMiddle, CursorMovePageEnd, + SetLineMode(LineMode), + ParentCursorMoveUp { offset: usize, }, diff --git a/src/key_command/constants.rs b/src/key_command/constants.rs index c3bddc9..de25d3a 100644 --- a/src/key_command/constants.rs +++ b/src/key_command/constants.rs @@ -71,6 +71,7 @@ cmd_constants![ (CMD_TOGGLE_HIDDEN, "toggle_hidden"), (CMD_TOGGLE_VISUAL, "toggle_visual"), (CMD_SWITCH_LINE_NUMBERS, "line_nums"), + (CMD_SET_LINEMODE, "linemode"), (CMD_TOUCH_FILE, "touch"), (CMD_HELP, "help"), (CMD_SEARCH_FZF, "search_fzf"), diff --git a/src/key_command/impl_appcommand.rs b/src/key_command/impl_appcommand.rs index bc509af..6f5c067 100644 --- a/src/key_command/impl_appcommand.rs +++ b/src/key_command/impl_appcommand.rs @@ -79,6 +79,7 @@ impl AppCommand for Command { Self::SubProcess { spawn: false, .. } => CMD_SUBPROCESS_FOREGROUND, Self::SubProcess { spawn: true, .. } => CMD_SUBPROCESS_BACKGROUND, Self::SwitchLineNums(_) => CMD_SWITCH_LINE_NUMBERS, + Self::SetLineMode(_) => CMD_SET_LINEMODE, Self::TabSwitch { .. } => CMD_TAB_SWITCH, Self::TabSwitchIndex { .. } => CMD_TAB_SWITCH_INDEX, diff --git a/src/key_command/impl_appexecute.rs b/src/key_command/impl_appexecute.rs index f72aca3..693ef0c 100644 --- a/src/key_command/impl_appexecute.rs +++ b/src/key_command/impl_appexecute.rs @@ -111,6 +111,7 @@ impl AppExecute for Command { Self::SetMode => set_mode::set_mode(context, backend), Self::ShowTasks => show_tasks::show_tasks(context, backend, keymap_t), Self::Sort(t) => sort::set_sort(context, *t), + Self::SetLineMode(mode) => linemode::set_linemode(context, *mode), Self::SortReverse => sort::toggle_reverse(context), Self::SubProcess { words, spawn } => { sub_process::sub_process(context, backend, words.as_slice(), *spawn) diff --git a/src/key_command/impl_comment.rs b/src/key_command/impl_comment.rs index b74da7a..5fb969f 100644 --- a/src/key_command/impl_comment.rs +++ b/src/key_command/impl_comment.rs @@ -1,4 +1,4 @@ -use crate::config::option::SortType; +use crate::config::option::{LineMode, SortType}; use crate::io::FileOperationOptions; use super::{Command, CommandComment}; @@ -7,6 +7,11 @@ impl CommandComment for Command { // These comments are displayed at the help page fn comment(&self) -> &'static str { match self { + Self::SetLineMode(linemode) => match linemode { + LineMode::Size => "Show files with size", + LineMode::MTime => "Show files with modified time", + LineMode::SizeMTime => "Show files with size and modified time", + }, Self::Escape => "Escape from visual mode (cancel)", Self::BulkRename => "Bulk rename", diff --git a/src/key_command/impl_from_str.rs b/src/key_command/impl_from_str.rs index 5802573..f7fe4e9 100644 --- a/src/key_command/impl_from_str.rs +++ b/src/key_command/impl_from_str.rs @@ -4,7 +4,7 @@ use dirs_next::home_dir; use shellexpand::tilde_with_context; use crate::commands::quit::QuitAction; -use crate::config::option::{LineNumberStyle, SelectOption, SortType}; +use crate::config::option::{LineMode, LineNumberStyle, SelectOption, SortType}; use crate::error::{JoshutoError, JoshutoErrorKind}; use crate::io::FileOperationOptions; @@ -334,6 +334,8 @@ impl std::str::FromStr for Command { )), }, } + } else if command == CMD_SET_LINEMODE { + Ok(Self::SetLineMode(LineMode::from_string(arg)?)) } else if command == CMD_TAB_SWITCH { match arg.parse::<i32>() { Ok(s) => Ok(Self::TabSwitch { offset: s }), |