aboutsummaryrefslogtreecommitdiff
path: root/helix-view/src/keymap.rs
diff options
context:
space:
mode:
authorBlaž Hrastnik2020-10-07 05:06:25 +0000
committerGitHub2020-10-07 05:06:25 +0000
commit6848702b1f09dc1a4e8d2e3067d3b45b3421d403 (patch)
tree18cc823d2a5dfd0b09b5802f6eb11c978080df36 /helix-view/src/keymap.rs
parentb7e1c0cf8253703a5eeb8453de23c8d0a6137ef1 (diff)
parent7f07e6676801be72e5a58b5612893c7d16f94a64 (diff)
Merge pull request #3 from helix-editor/goto-implementation
Goto mode implementation
Diffstat (limited to 'helix-view/src/keymap.rs')
-rw-r--r--helix-view/src/keymap.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/helix-view/src/keymap.rs b/helix-view/src/keymap.rs
index ef23ff2a..72fc0e79 100644
--- a/helix-view/src/keymap.rs
+++ b/helix-view/src/keymap.rs
@@ -108,6 +108,15 @@ macro_rules! shift {
};
}
+macro_rules! ctrl {
+ ($ch:expr) => {
+ Key {
+ code: KeyCode::Char($ch),
+ modifiers: Modifiers::CONTROL,
+ }
+ };
+}
+
pub fn default() -> Keymaps {
hashmap!(
state::Mode::Normal =>
@@ -126,6 +135,7 @@ pub fn default() -> Keymaps {
vec![key!('w')] => commands::move_next_word_start,
vec![key!('b')] => commands::move_prev_word_start,
vec![key!('e')] => commands::move_next_word_end,
+ vec![key!('g')] => commands::goto_mode,
vec![key!('i')] => commands::insert_mode,
vec![shift!('I')] => commands::prepend_to_line,
vec![key!('a')] => commands::append_mode,
@@ -139,6 +149,16 @@ pub fn default() -> Keymaps {
code: KeyCode::Esc,
modifiers: Modifiers::NONE
}] => commands::normal_mode,
+ vec![Key {
+ code: KeyCode::PageUp,
+ modifiers: Modifiers::NONE
+ }] => commands::page_up,
+ vec![Key {
+ code: KeyCode::PageDown,
+ modifiers: Modifiers::NONE
+ }] => commands::page_down,
+ vec![ctrl!('u')] => commands::half_page_up,
+ vec![ctrl!('d')] => commands::half_page_down,
),
state::Mode::Insert => hashmap!(
vec![Key {
@@ -161,6 +181,14 @@ pub fn default() -> Keymaps {
code: KeyCode::Tab,
modifiers: Modifiers::NONE
}] => commands::insert_tab,
+ ),
+ state::Mode::Goto => hashmap!(
+ vec![Key {
+ code: KeyCode::Esc,
+ modifiers: Modifiers::NONE
+ }] => commands::normal_mode as Command,
+ vec![key!('g')] => commands::move_file_start as Command,
+ vec![key!('e')] => commands::move_file_end as Command,
)
)
}