diff options
author | bptato <nincsnevem662@gmail.com> | 2023-12-09 14:43:10 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2023-12-09 16:36:23 +0100 |
commit | 6a1b1a2edfc6adf3d1d1a1aaa2c9fd95eccc8ff7 (patch) | |
tree | f2760bbb12b79925fa1c87dde9e05ddd74310683 /src | |
parent | 14f5605061501fa56d9b4970571858f6451e4710 (diff) | |
download | chawan-6a1b1a2edfc6adf3d1d1a1aaa2c9fd95eccc8ff7.tar.gz |
pager: add `{', `}'; document externInto
{ & } acts like in vi (except the cursor is not moved to the line beginning). No reason to leave externInto undocumented, as it is even used in the default config.
Diffstat (limited to 'src')
-rw-r--r-- | src/local/container.nim | 14 | ||||
-rw-r--r-- | src/server/buffer.nim | 21 |
2 files changed, 34 insertions, 1 deletions
diff --git a/src/local/container.nim b/src/local/container.nim index 2a0051e6..7cb67862 100644 --- a/src/local/container.nim +++ b/src/local/container.nim @@ -850,6 +850,20 @@ proc cursorPrevLink*(container: Container) {.jsfunc.} = if res.x > -1 and res.y != -1: container.setCursorXYCenter(res.x, res.y)) +proc cursorNextParagraph*(container: Container, n = 1) {.jsfunc.} = + container.iface + .findNextParagraph(container.cursory, n) + .then(proc(res: int) = + container.setCursorY(res) + ) + +proc cursorPrevParagraph*(container: Container, n = 1) {.jsfunc.} = + container.iface + .findPrevParagraph(container.cursory, n) + .then(proc(res: int) = + container.setCursorY(res) + ) + proc cursorNthLink*(container: Container, n = 1) {.jsfunc.} = container.iface .findNthLink(n) diff --git a/src/server/buffer.nim b/src/server/buffer.nim index e69af1fb..fff6f195 100644 --- a/src/server/buffer.nim +++ b/src/server/buffer.nim @@ -68,7 +68,8 @@ type CLICK, FIND_NEXT_LINK, FIND_PREV_LINK, FIND_NTH_LINK, FIND_REV_NTH_LINK, FIND_NEXT_MATCH, FIND_PREV_MATCH, GET_SOURCE, GET_LINES, UPDATE_HOVER, PASS_FD, CONNECT, CONNECT2, GOTO_ANCHOR, CANCEL, GET_TITLE, SELECT, - REDIRECT_TO_FD, READ_FROM_FD, SET_CONTENT_TYPE, CLONE + REDIRECT_TO_FD, READ_FROM_FD, SET_CONTENT_TYPE, CLONE, FIND_PREV_PARAGRAPH, + FIND_NEXT_PARAGRAPH # LOADING_PAGE: istream open # LOADING_RESOURCES: istream closed, resources open @@ -477,6 +478,24 @@ proc findNextLink*(buffer: Buffer, cursorx, cursory: int): tuple[x, y: int] {.pr inc i return (-1, -1) +proc findPrevParagraph*(buffer: Buffer, cursory, n: int): int {.proxy.} = + var y = cursory + for i in 0 ..< n: + while y >= 0 and buffer.lines[y].str.onlyWhitespace(): + dec y + while y >= 0 and not buffer.lines[y].str.onlyWhitespace(): + dec y + return y + +proc findNextParagraph*(buffer: Buffer, cursory, n: int): int {.proxy.} = + var y = cursory + for i in 0 ..< n: + while y < buffer.lines.len and buffer.lines[y].str.onlyWhitespace(): + inc y + while y < buffer.lines.len and not buffer.lines[y].str.onlyWhitespace(): + inc y + return y + proc findNthLink*(buffer: Buffer, i: int): tuple[x, y: int] {.proxy.} = if i == 0: return (-1, -1) |