diff options
author | Jan Hrastnik | 2020-10-04 21:47:37 +0000 |
---|---|---|
committer | Jan Hrastnik | 2020-10-04 21:47:37 +0000 |
commit | 038201647c657b2b07fa7f87aae3c609c59c77ef (patch) | |
tree | 263fd1c32f17f1aef5fdcce92d7a4fc21aa895f2 /helix-term/src/editor.rs | |
parent | b7e1c0cf8253703a5eeb8453de23c8d0a6137ef1 (diff) |
started work on goto mode
Diffstat (limited to 'helix-term/src/editor.rs')
-rw-r--r-- | helix-term/src/editor.rs | 16 |
1 files changed, 16 insertions, 0 deletions
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() { @@ -359,6 +362,19 @@ impl Editor { 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(); + } + } } } } |