aboutsummaryrefslogtreecommitdiff
path: root/helix-view/src
diff options
context:
space:
mode:
authorJan Hrastnik2020-09-30 23:15:42 +0000
committerJan Hrastnik2020-09-30 23:15:42 +0000
commitdd94a3981067a11c3d42caef32e3d9c93e1ec357 (patch)
tree72fa23293455342cae889c25575d4373e0ff81f7 /helix-view/src
parent592c5b0af22cc719fc1513f71706dad326ba8081 (diff)
moved insert keymap to keymap.rs
Diffstat (limited to 'helix-view/src')
-rw-r--r--helix-view/src/commands.rs4
-rw-r--r--helix-view/src/keymap.rs18
2 files changed, 22 insertions, 0 deletions
diff --git a/helix-view/src/commands.rs b/helix-view/src/commands.rs
index bdfa57ec..a3906b9b 100644
--- a/helix-view/src/commands.rs
+++ b/helix-view/src/commands.rs
@@ -280,6 +280,10 @@ pub fn insert_char(view: &mut View, c: char) {
// TODO: need to store into history if successful
}
+pub fn insert_newline(view: &mut View, _count: usize) {
+ insert_char(view, '\n');
+}
+
// TODO: handle indent-aware delete
pub fn delete_char_backward(view: &mut View, count: usize) {
let text = &view.state.doc.slice(..);
diff --git a/helix-view/src/keymap.rs b/helix-view/src/keymap.rs
index 078f2bf1..512dcbdb 100644
--- a/helix-view/src/keymap.rs
+++ b/helix-view/src/keymap.rs
@@ -182,6 +182,24 @@ pub fn default() -> Keymaps {
code: KeyCode::Esc,
modifiers: Modifiers::NONE
}] => commands::normal_mode as Command,
+ ),
+ state::Mode::Insert => hashmap!(
+ vec![Key {
+ code: KeyCode::Esc,
+ modifiers: Modifiers::NONE
+ }] => commands::normal_mode as Command,
+ vec![Key {
+ code: KeyCode::Backspace,
+ modifiers: Modifiers::NONE
+ }] => commands::delete_char_backward as Command,
+ vec![Key {
+ code: KeyCode::Delete,
+ modifiers: Modifiers::NONE
+ }] => commands::delete_char_forward as Command,
+ vec![Key {
+ code: KeyCode::Enter,
+ modifiers: Modifiers::NONE
+ }] => commands::insert_newline as Command,
)
)
}