aboutsummaryrefslogtreecommitdiffstats
path: root/src/local
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2025-02-13 18:53:36 +0100
committerbptato <nincsnevem662@gmail.com>2025-02-13 18:53:36 +0100
commite150db7084865f736e0af213120e0d9ba7786f6d (patch)
tree540ba0d84ea56eead08f585f4a30f011780123b2 /src/local
parent8f3c96035f22a16459ad7c8996c280a015f0d2f5 (diff)
downloadchawan-e150db7084865f736e0af213120e0d9ba7786f6d.tar.gz
pager: copy cursor position on meta refresh
Diffstat (limited to 'src/local')
-rw-r--r--src/local/container.nim2
-rw-r--r--src/local/pager.nim13
2 files changed, 8 insertions, 7 deletions
diff --git a/src/local/container.nim b/src/local/container.nim
index 9ffc816e..cb6ebdb5 100644
--- a/src/local/container.nim
+++ b/src/local/container.nim
@@ -1133,7 +1133,7 @@ proc popCursorPos*(container: Container; nojump = false) =
container.sendCursorPosition()
container.needslines = true
-proc copyCursorPos*(container, c2: Container) =
+proc copyCursorPos*(container, c2: Container) {.jsfunc.} =
if c2.startpos.isSome:
container.startpos = c2.startpos
else:
diff --git a/src/local/pager.nim b/src/local/pager.nim
index b0156c5f..8a5eb87f 100644
--- a/src/local/pager.nim
+++ b/src/local/pager.nim
@@ -2241,7 +2241,7 @@ type GotoURLDict = object of JSDict
save {.jsdefault.}: bool
history {.jsdefault.}: bool
-proc jsGotoURL(pager: Pager; v: JSValue; t = GotoURLDict()): JSResult[void]
+proc jsGotoURL(pager: Pager; v: JSValue; t = GotoURLDict()): JSResult[Container]
{.jsfunc: "gotoURL".} =
var request: Request = nil
var jsRequest: JSRequest = nil
@@ -2254,9 +2254,8 @@ proc jsGotoURL(pager: Pager; v: JSValue; t = GotoURLDict()): JSResult[void]
?pager.jsctx.fromJS(v, s)
url = ?newURL(s)
request = newRequest(url)
- discard pager.gotoURL(request, contentType = t.contentType.get(""),
- replace = t.replace.get(nil), save = t.save, history = t.history)
- return ok()
+ return ok(pager.gotoURL(request, contentType = t.contentType.get(""),
+ replace = t.replace.get(nil), save = t.save, history = t.history))
# Reload the page in a new buffer, then kill the previous buffer.
proc reload(pager: Pager) {.jsfunc.} =
@@ -2923,8 +2922,10 @@ proc metaRefresh(pager: Pager; container: Container; n: int; url: URL) =
let ctx = pager.jsctx
let fun = ctx.newFunction(["url", "replace"],
"""
-if (replace.alive)
- pager.gotoURL(url, {replace: replace, history: replace.history})
+if (replace.alive) {
+ const c2 = pager.gotoURL(url, {replace: replace, history: replace.history});
+ c2.copyCursorPos(replace)
+}
""")
let args = [ctx.toJS(url), ctx.toJS(container)]
discard pager.timeouts.setTimeout(ttTimeout, fun, int32(n), args)