From ed53ea6efbaf1470aea687e097bf2ecafb38220c Mon Sep 17 00:00:00 2001 From: sxyazi Date: Thu, 20 Jul 2023 06:44:26 +0800 Subject: [PATCH] feat: enable arrow keys by default --- config/keymap.toml | 24 +++++++++++++++++++----- config/theme.toml | 8 ++++---- src/ui/dispatcher.rs | 21 +++++++++++---------- 3 files changed, 34 insertions(+), 19 deletions(-) diff --git a/config/keymap.toml b/config/keymap.toml index a96eeb17..4f164326 100644 --- a/config/keymap.toml +++ b/config/keymap.toml @@ -6,11 +6,11 @@ keymap = [ { on = [ "" ], exec = "close" }, # Navigation - { on = [ "j" ], exec = "arrow 1" }, { on = [ "k" ], exec = "arrow -1" }, + { on = [ "j" ], exec = "arrow 1" }, - { on = [ "J" ], exec = "arrow 5" }, { on = [ "K" ], exec = "arrow -5" }, + { on = [ "J" ], exec = "arrow 5" }, { on = [ "h" ], exec = "leave" }, { on = [ "l" ], exec = "enter" }, @@ -18,6 +18,11 @@ keymap = [ { on = [ "H" ], exec = "back" }, { on = [ "L" ], exec = "forward" }, + { on = [ "" ], exec = "arrow -1" }, + { on = [ "" ], exec = "arrow 1" }, + { on = [ "" ], exec = "leave" }, + { on = [ "" ], exec = "enter" }, + # Selection { on = [ "" ], exec = "select --state=none" }, { on = [ "v" ], exec = "visual_mode" }, @@ -71,8 +76,11 @@ keymap = [ { on = [ "" ], exec = "close" }, { on = [ "w" ], exec = "close" }, - { on = [ "j" ], exec = "arrow 1" }, { on = [ "k" ], exec = "arrow -1" }, + { on = [ "j" ], exec = "arrow 1" }, + + { on = [ "" ], exec = "arrow -1" }, + { on = [ "" ], exec = "arrow 1" }, { on = [ "x" ], exec = "cancel" }, ] @@ -84,11 +92,14 @@ keymap = [ { on = [ "" ], exec = "close" }, { on = [ "" ], exec = "close --submit" }, - { on = [ "j" ], exec = "arrow 1" }, { on = [ "k" ], exec = "arrow -1" }, + { on = [ "j" ], exec = "arrow 1" }, - { on = [ "J" ], exec = "arrow 5" }, { on = [ "K" ], exec = "arrow -5" }, + { on = [ "J" ], exec = "arrow 5" }, + + { on = [ "" ], exec = "arrow -1" }, + { on = [ "" ], exec = "arrow 1" }, ] [input] @@ -110,6 +121,9 @@ keymap = [ { on = [ "H" ], exec = "move -999" }, { on = [ "L" ], exec = "move 999" }, + { on = [ "" ], exec = "move -1" }, + { on = [ "" ], exec = "move 1" }, + { on = [ "b" ], exec = "backward" }, { on = [ "w" ], exec = "forward" }, { on = [ "e" ], exec = "forward --end-of-word" }, diff --git a/config/theme.toml b/config/theme.toml index 500548e6..40539eaa 100644 --- a/config/theme.toml +++ b/config/theme.toml @@ -94,10 +94,10 @@ rules = [ "*.wav" = "" # Movies -"*.mp4" = "" -"*.mkv" = "" -"*.avi" = "" -"*.mov" = "" +"*.mp4" = "" +"*.mkv" = "" +"*.avi" = "" +"*.mov" = "" # Images "*.jpg" = "" diff --git a/src/ui/dispatcher.rs b/src/ui/dispatcher.rs index af38da4a..2f4b0a79 100644 --- a/src/ui/dispatcher.rs +++ b/src/ui/dispatcher.rs @@ -178,27 +178,28 @@ impl Executor { return false; }; + match exec.cmd.as_str() { + "close" => return cx.input.close(exec.named.contains_key("submit")), + "escape" => return cx.input.escape(), + + "move" => { + let step = exec.args.get(0).and_then(|s| s.parse().ok()).unwrap_or(0); + return cx.input.move_(step); + } + _ => {} + } + match cx.input.mode() { InputMode::Normal => match exec.cmd.as_str() { - "close" => cx.input.close(exec.named.contains_key("submit")), - "escape" => cx.input.escape(), - "insert" => cx.input.insert(exec.named.contains_key("append")), "visual" => cx.input.visual(), - "move" => { - let step = exec.args.get(0).and_then(|s| s.parse().ok()).unwrap_or(0); - cx.input.move_(step) - } - "backward" => cx.input.backward(), "forward" => cx.input.forward(exec.named.contains_key("end-of-word")), "delete" => cx.input.delete(exec.named.contains_key("insert")), _ => false, }, InputMode::Insert => match exec.cmd.as_str() { - "close" => cx.input.close(exec.named.contains_key("submit")), - "escape" => cx.input.escape(), "backspace" => cx.input.backspace(), _ => { if let KeyCode::Char(c) = code {