diff options
author | bptato <nincsnevem662@gmail.com> | 2024-03-30 14:48:25 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2024-03-30 15:07:31 +0100 |
commit | aaf23561d1704e6d178c4acabdfa87a73cd62e9c (patch) | |
tree | 396d71b75172302114c3b53c9f4b8680bd43f869 | |
parent | 290f82240f429ae4284aa385f0e40c59ef25a07a (diff) | |
download | chawan-aaf23561d1704e6d178c4acabdfa87a73cd62e9c.tar.gz |
pager: fix weird halfPage* behavior
For some reason, halfPageDown decremented height instead of incrementing it, which caused some rather weird behavior where halfPageUp + halfPageDown would put the cursor in a different position than it was before. Also, we must increment *before* dividing to mimic vi behavior properly.
-rw-r--r-- | src/local/container.nim | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/local/container.nim b/src/local/container.nim index 3772b0b0..022c40f2 100644 --- a/src/local/container.nim +++ b/src/local/container.nim @@ -916,20 +916,20 @@ proc pageRight(container: Container, n = 1) {.jsfunc.} = # Users who disagree are free to implement it themselves. (It is about # 5 lines of JS.) proc halfPageUp(container: Container, n = 1) {.jsfunc.} = - container.setFromY(container.fromy - (container.height div 2 + 1) * n) - container.setCursorY(container.cursory - (container.height div 2 + 1) * n) + container.setFromY(container.fromy - (container.height + 1) div 2 * n) + container.setCursorY(container.cursory - (container.height + 1) div 2 * n) container.restoreCursorX() proc halfPageDown(container: Container, n = 1) {.jsfunc.} = - container.setFromY(container.fromy + (container.height div 2 - 1) * n) - container.setCursorY(container.cursory + (container.height div 2 - 1) * n) + container.setFromY(container.fromy + (container.height + 1) div 2 * n) + container.setCursorY(container.cursory + (container.height + 1) div 2 * n) container.restoreCursorX() proc halfPageLeft(container: Container, n = 1) {.jsfunc.} = - container.setFromX(container.fromx - (container.width div 2 + 1) * n) + container.setFromX(container.fromx - (container.width + 1) div 2 * n) proc halfPageRight(container: Container, n = 1) {.jsfunc.} = - container.setFromX(container.fromx + (container.width div 2 - 1) * n) + container.setFromX(container.fromx + (container.width + 1) div 2 * n) proc markPos0*(container: Container) = container.tmpJumpMark = (container.cursorx, container.cursory) |