diff options
-rw-r--r-- | doc/config.md | 5 | ||||
-rw-r--r-- | res/config.toml | 3 | ||||
-rw-r--r-- | src/buffer/container.nim | 9 |
3 files changed, 16 insertions, 1 deletions
diff --git a/doc/config.md b/doc/config.md index 0f986de4..cde6b1f4 100644 --- a/doc/config.md +++ b/doc/config.md @@ -584,6 +584,11 @@ Note: this does not suspend buffer processes.</td> </tr> <tr> +<td>`pager.cursorLineTextStart()`</td> +<td>Move the cursor to the first non-blank character of the line.</td> +</tr> + +<tr> <td>`pager.cursorLineEnd()`</td> <td>Move the cursor to the last cell of the line.</td> </tr> diff --git a/res/config.toml b/res/config.toml index 88e4e775..b96f05d8 100644 --- a/res/config.toml +++ b/res/config.toml @@ -67,7 +67,8 @@ l = 'pager.cursorRight()' 'M-[B' = 'pager.cursorDown()' 'M-[A' = 'pager.cursorUp()' 'M-[C' = 'pager.cursorRight()' -'^' = 'pager.cursorLineBegin()' +'0' = 'pager.cursorLineBegin()' +'^' = 'pager.cursorLineTextStart()' '$' = 'pager.cursorLineEnd()' b = 'pager.cursorPrevWord()' w = 'pager.cursorNextWord()' 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) |