summaryrefslogtreecommitdiffstats
path: root/src/commands/key_command.rs
diff options
context:
space:
mode:
authorJiayi Zhao <jeff.no.zhao@gmail.com>2020-11-22 21:51:51 -0500
committerJiayi Zhao <jeff.no.zhao@gmail.com>2020-11-22 21:51:51 -0500
commit0e3ee5aa31368a1501e24beb33ae1020c0ac332e (patch)
tree3313c5002661ba0f04e74256559b6f13964b5616 /src/commands/key_command.rs
parent29b19b1f1172632a1ef68a232d1058149be87c4a (diff)
add support for moving parent cursor
Diffstat (limited to 'src/commands/key_command.rs')
-rw-r--r--src/commands/key_command.rs34
1 files changed, 32 insertions, 2 deletions
diff --git a/src/commands/key_command.rs b/src/commands/key_command.rs
index 97e655b..e5a2514 100644
--- a/src/commands/key_command.rs
+++ b/src/commands/key_command.rs
@@ -28,6 +28,9 @@ pub enum KeyCommand {
CursorMovePageUp,
CursorMovePageDown,
+ ParentCursorMoveUp(usize),
+ ParentCursorMoveDown(usize),
+
DeleteFiles,
NewDirectory(path::PathBuf),
OpenFile,
@@ -79,6 +82,9 @@ impl KeyCommand {
Self::CursorMovePageUp => "cursor_move_page_up",
Self::CursorMovePageDown => "cursor_move_page_down",
+ Self::ParentCursorMoveUp(_) => "parent_cursor_move_up",
+ Self::ParentCursorMoveDown(_) => "parent_cursor_move_down",
+
Self::DeleteFiles => "delete_files",
Self::NewDirectory(_) => "new_directory",
Self::OpenFile => "open",
@@ -155,6 +161,26 @@ impl KeyCommand {
)),
},
},
+ "parent_cursor_move_down" => match arg {
+ "" => Ok(Self::ParentCursorMoveDown(1)),
+ arg => match arg.parse::<usize>() {
+ Ok(s) => Ok(Self::ParentCursorMoveDown(s)),
+ Err(e) => Err(JoshutoError::new(
+ JoshutoErrorKind::ParseError,
+ e.to_string(),
+ )),
+ },
+ },
+ "parent_cursor_move_up" => match arg {
+ "" => Ok(Self::ParentCursorMoveUp(1)),
+ arg => match arg.parse::<usize>() {
+ Ok(s) => Ok(Self::ParentCursorMoveUp(s)),
+ Err(e) => Err(JoshutoError::new(
+ JoshutoErrorKind::ParseError,
+ e.to_string(),
+ )),
+ },
+ },
"cut_files" => Ok(Self::CutFiles),
"delete_files" => Ok(Self::DeleteFiles),
"force_quit" => Ok(Self::ForceQuit),
@@ -290,6 +316,9 @@ impl JoshutoRunnable for KeyCommand {
Self::CursorMovePageUp => cursor_move::page_up(context, backend),
Self::CursorMovePageDown => cursor_move::page_down(context, backend),
+ Self::ParentCursorMoveUp(u) => parent_cursor_move::parent_up(context, *u),
+ Self::ParentCursorMoveDown(u) => parent_cursor_move::parent_down(context, *u),
+
Self::DeleteFiles => {
delete_files::delete_selected_files(context, backend)?;
Ok(())
@@ -338,8 +367,9 @@ impl std::fmt::Display for KeyCommand {
Self::RenameFile(name) => write!(f, "{} {:?}", self.command(), name),
Self::Search(s) => write!(f, "{} {}", self.command(), s),
- Self::SelectFiles { toggle, all } => write!(f, "{} toggle={} all={}",
- self.command(), toggle, all),
+ Self::SelectFiles { toggle, all } => {
+ write!(f, "{} toggle={} all={}", self.command(), toggle, all)
+ }
Self::ShellCommand(c) => write!(f, "{} {:?}", self.command(), c),
Self::Sort(t) => write!(f, "{} {}", self.command(), t),
Self::TabSwitch(i) => write!(f, "{} {}", self.command(), i),