diff options
author | bptato <nincsnevem662@gmail.com> | 2022-11-29 13:13:50 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2022-11-29 13:13:50 +0100 |
commit | 00b54f6fff8eb001950689650d595c2b23a3f639 (patch) | |
tree | 4602b9ae4c6abc842673411831540469db7b0a3b /src/display | |
parent | d7a05e7a58d0c2de3078fc9854534974c7e347d4 (diff) | |
download | chawan-00b54f6fff8eb001950689650d595c2b23a3f639.tar.gz |
Restore cursor position on reload
Diffstat (limited to 'src/display')
-rw-r--r-- | src/display/pager.nim | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/display/pager.nim b/src/display/pager.nim index d60196cd..2abcd6c6 100644 --- a/src/display/pager.nim +++ b/src/display/pager.nim @@ -317,7 +317,7 @@ proc dupeBuffer*(pager: Pager, location = none(URL)) {.jsfunc.} = # The prevBuffer and nextBuffer procedures emulate w3m's PREV and NEXT # commands by traversing the container tree in a depth-first order. -proc prevBuffer*(pager: Pager): bool {.jsfunc.} = +proc prevBuffer(pager: Pager): bool {.jsfunc.} = if pager.container == nil: return false if pager.container.parent == nil: @@ -330,7 +330,7 @@ proc prevBuffer*(pager: Pager): bool {.jsfunc.} = pager.setContainer(pager.container.parent) return true -proc nextBuffer*(pager: Pager): bool {.jsfunc.} = +proc nextBuffer(pager: Pager): bool {.jsfunc.} = if pager.container == nil: return false if pager.container.children.len > 0: @@ -385,7 +385,7 @@ proc deleteContainer(pager: Pager, container: Container) = pager.unreg.add((container.process, SocketStream(container.iface.stream))) pager.dispatcher.forkserver.removeChild(container.process) -proc discardBuffer*(pager: Pager) {.jsfunc.} = +proc discardBuffer(pager: Pager) {.jsfunc.} = if pager.container == nil or pager.container.parent == nil and pager.container.children.len == 0: pager.alert("Cannot discard last buffer!") @@ -429,7 +429,9 @@ proc gotoURL*(pager: Pager, request: Request, prevurl = none(URL), ctype = none( location: request.url ) let container = pager.dispatcher.newBuffer(pager.config, source) - container.replace = replace + if replace != nil: + container.replace = replace + container.copyCursorPos(container.replace) pager.addContainer(container) else: pager.container.findAnchor(request.url.anchor) |