diff options
author | bptato <nincsnevem662@gmail.com> | 2024-01-19 01:43:46 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2024-01-19 01:53:28 +0100 |
commit | 3c156384bade3e0e86a837b1b423d401af3cfdd2 (patch) | |
tree | f8cd1b8e82510a0bb2ef1a02de877f00617c965e /src/display | |
parent | 58ae65ed182a8a78d67756ec62f30261b9ef6c87 (diff) | |
download | chawan-3c156384bade3e0e86a837b1b423d401af3cfdd2.tar.gz |
Re-design word handling, add e, E, W, B, etc.
* Add functions for moving to the beginning/end of words (vi `b', `e'). * As it turns out, there are many possible interpretations of what a word is. Now we have a function for each reasonable interpretation, and the default settings match those of vi (and w3m in w3m.toml). (Exception: it's still broken on line boundaries... TODO) * Remove `bounds` from lineedit, it was horrible API design and mostly useless. In the future, an API similar to what pager now has could be added. * Update docs, and fix some spacing issues with symbols in the tables.
Diffstat (limited to 'src/display')
-rw-r--r-- | src/display/lineedit.nim | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/display/lineedit.nim b/src/display/lineedit.nim index 7eef9bfb..7a5067eb 100644 --- a/src/display/lineedit.nim +++ b/src/display/lineedit.nim @@ -208,50 +208,50 @@ proc forward(edit: LineEdit) {.jsfunc.} = if edit.cursorx >= edit.shiftx + edit.maxwidth: edit.invalid = true -proc prevWord(edit: LineEdit, check = opt(BoundaryFunction)) {.jsfunc.} = +proc prevWord(edit: LineEdit) {.jsfunc.} = if edit.cursori == 0: return let (r, len) = edit.news.lastRune(edit.cursori - 1) - if r.breaksWord(check): + if r.breaksWord(): edit.cursori -= len edit.cursorx -= r.width() while edit.cursori > 0: let (r, len) = edit.news.lastRune(edit.cursori - 1) - if r.breaksWord(check): + if r.breaksWord(): break edit.cursori -= len edit.cursorx -= r.width() if edit.cursorx < edit.shiftx: edit.invalid = true -proc nextWord(edit: LineEdit, check = opt(BoundaryFunction)) {.jsfunc.} = +proc nextWord(edit: LineEdit) {.jsfunc.} = if edit.cursori >= edit.news.len: return let oc = edit.cursori var r: Rune fastRuneAt(edit.news, edit.cursori, r) - if r.breaksWord(check): + if r.breaksWord(): edit.cursorx += r.width() else: edit.cursori = oc while edit.cursori < edit.news.len: let pc = edit.cursori fastRuneAt(edit.news, edit.cursori, r) - if r.breaksWord(check): + if r.breaksWord(): edit.cursori = pc break edit.cursorx += r.width() if edit.cursorx >= edit.shiftx + edit.maxwidth: edit.invalid = true -proc clearWord(edit: LineEdit, check = opt(BoundaryFunction)) {.jsfunc.} = +proc clearWord(edit: LineEdit) {.jsfunc.} = let oc = edit.cursori - edit.prevWord(check) + edit.prevWord() if oc != edit.cursori: edit.news.delete(edit.cursori .. oc - 1) edit.invalid = true -proc killWord(edit: LineEdit, check = opt(BoundaryFunction)) {.jsfunc.} = +proc killWord(edit: LineEdit) {.jsfunc.} = if edit.cursori >= edit.news.len: return let oc = edit.cursori |