about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-09-08 17:21:35 +0200
committerbptato <nincsnevem662@gmail.com>2023-09-08 17:26:53 +0200
commit099550625e55ad59a6ed6bef54ad0d86470cdd91 (patch)
treede3fc24858cfc3450ad7fe719c96725b21d692ea /src
parentbf5f9d42fb90c2d8b989e73ffe051cf62a865be1 (diff)
downloadchawan-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.nim9
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)