on master help sign in
Parse input counts: 10w, etc.
de5170dBlaž Hrastnik
TODO.md+1−1
@@ -11,7 +11,7 @@
11- [ ] selection mode
11- [ ] selection mode
12- [x] % for whole doc selection
12- [x] % for whole doc selection
13- [x] vertical splits
13- [x] vertical splits
14−- [ ] input counts (30j)
14+- [x] input counts (30j)
15- [ ] respect view fullscreen flag
15- [ ] respect view fullscreen flag
16- [ ] retain horiz when moving vertically
16- [ ] retain horiz when moving vertically
17- [ ] update lsp on redo/undo
17- [ ] update lsp on redo/undo
helix-term/src/ui/editor.rs+22−5
@@ -9,7 +9,7 @@ use std::borrow::Cow;
9
9
10use crossterm::{
10use crossterm::{
11 cursor,
11 cursor,
12− event::{read, Event, EventStream, KeyCode, KeyEvent},
12+ event::{read, Event, EventStream, KeyCode, KeyEvent, KeyModifiers},
13};
13};
14use tui::{
14use tui::{
15 backend::CrosstermBackend,
15 backend::CrosstermBackend,
@@ -333,10 +333,27 @@ impl Component for EditorView {
333 }
333 }
334 }
334 }
335 mode => {
335 mode => {
336+ match keys.as_slice() {
337+ &[KeyEvent {
338+ code: KeyCode::Char(i @ '0'..='9'),
339+ modifiers: KeyModifiers::NONE,
340+ }] => {
341+ let i = i.to_digit(10).unwrap() as usize;
342+ cxt.editor.count = Some(cxt.editor.count.map_or(i, |c| c * 10 + i));
343+ }
344+ _ => {
345+ // set the count
346+ cxt.count = cxt.editor.count.take().unwrap_or(1);
347+ // TODO: edge case: 0j -> reset to 1
348+ // if this fails, count was Some(0)
349+ // debug_assert!(cxt.count != 0);
350+
336− if let Some(command) = self.keymap[&mode].get(&keys) {
351+ if let Some(command) = self.keymap[&mode].get(&keys) {
337− command(&mut cxt);
352+ command(&mut cxt);
338−
353+
339− // TODO: simplistic ensure cursor in view for now
354+ // TODO: simplistic ensure cursor in view for now
355+ }
356+ }
340 }
357 }
341 }
358 }
342 }
359 }
helix-view/src/editor.rs+2
@@ -10,6 +10,7 @@ pub struct Editor {
10 pub tree: Tree,
10 pub tree: Tree,
11 // pub documents: Vec<Document>,
11 // pub documents: Vec<Document>,
12 pub should_close: bool,
12 pub should_close: bool,
13+ pub count: Option<usize>,
13 pub theme: Theme, // TODO: share one instance
14 pub theme: Theme, // TODO: share one instance
14 pub language_servers: helix_lsp::Registry,
15 pub language_servers: helix_lsp::Registry,
15}
16}
@@ -25,6 +26,7 @@ impl Editor {
25 Self {
26 Self {
26 tree: Tree::new(area),
27 tree: Tree::new(area),
27 should_close: false,
28 should_close: false,
29+ count: None,
28 theme,
30 theme,
29 language_servers,
31 language_servers,
30 }
32 }