aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-02-12 23:56:09 +0100
committerbptato <nincsnevem662@gmail.com>2024-02-12 23:57:06 +0100
commit261b0fca3e7da6328d382ae752c36d374272342a (patch)
tree5f18a62b85c941407ec8ea0eb0c160b5b93a2a8a /src
parent1960de266d72eb9f3b5c025f1325c116d8d09319 (diff)
downloadchawan-261b0fca3e7da6328d382ae752c36d374272342a.tar.gz
container: do not reshape twice on loading documents
Diffstat (limited to 'src')
-rw-r--r--src/local/container.nim36
1 files changed, 18 insertions, 18 deletions
diff --git a/src/local/container.nim b/src/local/container.nim
index a66104f4..49b93eff 100644
--- a/src/local/container.nim
+++ b/src/local/container.nim
@@ -1334,35 +1334,34 @@ proc onload*(container: Container, res: LoadResult) =
# HTML.
container.iface.cancel().then(proc(lines: int) =
container.setNumLines(lines)
- container.needslines = true)
+ container.needslines = true
+ )
else:
if res.bytes == -1 or res.atend:
container.setLoadInfo("")
elif not res.atend:
container.setLoadInfo(convertSize(res.bytes) & " loaded")
- if res.lines > container.numLines:
- container.setNumLines(res.lines)
+ if res.lines > container.numLines or res.atend:
+ container.setNumLines(res.lines, res.atend)
container.triggerEvent(STATUS)
container.needslines = true
if not res.atend:
discard container.iface.load().then(proc(res: LoadResult) =
- container.onload(res))
+ container.onload(res)
+ )
else:
- container.iface.getTitle().then(proc(title: string): auto =
+ container.triggerEvent(LOADED)
+ container.iface.getTitle().then(proc(title: string) =
if title != "":
container.title = title
container.triggerEvent(TITLE)
- return container.iface.render()
- ).then(proc(lines: int): auto =
- container.setNumLines(lines, true)
- container.needslines = true
- container.triggerEvent(LOADED)
- if not container.hasstart and container.location.anchor != "":
- return container.iface.gotoAnchor()
- ).then(proc(res: Opt[tuple[x, y: int]]) =
- if res.isSome:
- let res = res.get
- container.setCursorXYCenter(res.x, res.y))
+ )
+ if not container.hasstart and container.location.anchor != "":
+ container.iface.gotoAnchor().then(proc(res: Opt[tuple[x, y: int]]) =
+ if res.isSome:
+ let res = res.get
+ container.setCursorXYCenter(res.x, res.y)
+ )
proc load(container: Container) =
container.setLoadInfo("Connecting to " & container.location.host & "...")
@@ -1455,10 +1454,11 @@ proc readSuccess*(container: Container, s: string) =
if res.open.isSome:
container.triggerEvent(ContainerEvent(t: OPEN, request: res.open.get)))
-proc reshape(container: Container): EmptyPromise {.discardable, jsfunc.} =
+proc reshape(container: Container): EmptyPromise {.jsfunc.} =
return container.iface.render().then(proc(lines: int): auto =
container.setNumLines(lines)
- return container.requestLines())
+ return container.requestLines()
+ )
proc onclick(container: Container, res: ClickResult)