From 038201647c657b2b07fa7f87aae3c609c59c77ef Mon Sep 17 00:00:00 2001 From: Jan Hrastnik Date: Sun, 4 Oct 2020 23:47:37 +0200 Subject: started work on goto mode --- helix-term/src/editor.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'helix-term/src/editor.rs') diff --git a/helix-term/src/editor.rs b/helix-term/src/editor.rs index 70b5758e..266c0198 100644 --- a/helix-term/src/editor.rs +++ b/helix-term/src/editor.rs @@ -254,6 +254,7 @@ impl Editor { let mode = match view.state.mode() { Mode::Insert => "INS", Mode::Normal => "NOR", + Mode::Goto => "GOTO", }; self.surface.set_style( Rect::new(0, self.size.1 - 1, self.size.0, 1), @@ -278,6 +279,7 @@ impl Editor { match view.state.mode() { Mode::Insert => write!(stdout, "\x1B[6 q"), Mode::Normal => write!(stdout, "\x1B[2 q"), + Mode::Goto => write!(stdout, "\x1B[2 q"), }; // render the cursor @@ -326,6 +328,7 @@ impl Editor { }))) => { break; } + Some(Ok(Event::Key(event))) => { if let Some(view) = &mut self.view { match view.state.mode() { @@ -356,6 +359,19 @@ impl Editor { // TODO: simplistic ensure cursor in view for now view.ensure_cursor_in_view(); + self.render(); + } + } + Mode::Goto => { + // TODO: handle modes and sequences (`gg`) + let keys = vec![event]; + if let Some(command) = keymap[&Mode::Goto].get(&keys) { + // TODO: handle count other than 1 + command(view, 1); + + // TODO: simplistic ensure cursor in view for now + view.ensure_cursor_in_view(); + self.render(); } } -- cgit v1.2.3-70-g09d2