|
|
@ -320,29 +320,20 @@ impl Editor {
|
|
|
|
if let Some(view) = &mut self.view {
|
|
|
|
if let Some(view) = &mut self.view {
|
|
|
|
match view.state.mode() {
|
|
|
|
match view.state.mode() {
|
|
|
|
Mode::Insert => {
|
|
|
|
Mode::Insert => {
|
|
|
|
match event {
|
|
|
|
// TODO: handle modes and sequences (`gg`)
|
|
|
|
KeyEvent {
|
|
|
|
let keys = vec![event];
|
|
|
|
code: KeyCode::Esc, ..
|
|
|
|
if let Some(command) = keymap[&Mode::Insert].get(&keys) {
|
|
|
|
} => commands::normal_mode(view, 1),
|
|
|
|
// TODO: handle count other than 1
|
|
|
|
KeyEvent {
|
|
|
|
command(view, 1);
|
|
|
|
code: KeyCode::Backspace,
|
|
|
|
} else {
|
|
|
|
..
|
|
|
|
if let KeyEvent {
|
|
|
|
} => commands::delete_char_backward(view, 1),
|
|
|
|
|
|
|
|
KeyEvent {
|
|
|
|
|
|
|
|
code: KeyCode::Delete,
|
|
|
|
|
|
|
|
..
|
|
|
|
|
|
|
|
} => commands::delete_char_forward(view, 1),
|
|
|
|
|
|
|
|
KeyEvent {
|
|
|
|
|
|
|
|
code: KeyCode::Char(c),
|
|
|
|
code: KeyCode::Char(c),
|
|
|
|
..
|
|
|
|
..
|
|
|
|
} => commands::insert_char(view, c),
|
|
|
|
} = event
|
|
|
|
KeyEvent {
|
|
|
|
{
|
|
|
|
code: KeyCode::Enter,
|
|
|
|
commands::insert_char(view, c);
|
|
|
|
..
|
|
|
|
}
|
|
|
|
} => commands::insert_char(view, '\n'),
|
|
|
|
|
|
|
|
_ => (), // skip
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// TODO: simplistic ensure cursor in view for now
|
|
|
|
|
|
|
|
view.ensure_cursor_in_view();
|
|
|
|
view.ensure_cursor_in_view();
|
|
|
|
|
|
|
|
|
|
|
|
self.render();
|
|
|
|
self.render();
|
|
|
|