diff options
author | bptato <nincsnevem662@gmail.com> | 2023-09-08 17:21:35 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2023-09-08 17:26:53 +0200 |
commit | 099550625e55ad59a6ed6bef54ad0d86470cdd91 (patch) | |
tree | de3fc24858cfc3450ad7fe719c96725b21d692ea /src | |
parent | bf5f9d42fb90c2d8b989e73ffe051cf62a865be1 (diff) | |
download | chawan-099550625e55ad59a6ed6bef54ad0d86470cdd91.tar.gz |
container: add separate commands for 0 and ^
Just as in vi, 0 puts the cursor at the beginning of the current line, and ^ puts the cursor at the position of the first non-blank character.
Diffstat (limited to 'src')
-rw-r--r-- | src/buffer/container.nim | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/buffer/container.nim b/src/buffer/container.nim index 143c169b..0e31b672 100644 --- a/src/buffer/container.nim +++ b/src/buffer/container.nim @@ -447,6 +447,15 @@ proc cursorRight(container: Container) {.jsfunc.} = proc cursorLineBegin(container: Container) {.jsfunc.} = container.setCursorX(0) +proc cursorLineTextStart(container: Container) {.jsfunc.} = + if container.numLines == 0: return + var x = 0 + for r in container.currentLine.runes: + if not r.isWhitespace(): + break + x += r.twidth(x) + container.setCursorX(x) + proc cursorLineEnd(container: Container) {.jsfunc.} = container.setCursorX(container.currentLineWidth() - 1) |