diff options
| author | bptato <nincsnevem662@gmail.com> | 2024-02-27 17:39:58 +0100 |
|---|---|---|
| committer | bptato <nincsnevem662@gmail.com> | 2024-02-27 17:44:36 +0100 |
| commit | 29f4655f5c04eeabb07c7c27bd564e0b4ae896f5 (patch) | |
| tree | a9a9bd63512caf886b60c0e91bf042bacc78d93d /src | |
| parent | cf6d0df2240762a4a70edf44a89f8e5d73b0b0c0 (diff) | |
| download | chawan-29f4655f5c04eeabb07c7c27bd564e0b4ae896f5.tar.gz | |
buffer: reset prevStyled in switchCharset, reshape
reshape must do a render from zero, as it's a last resort for users to
fixup the page on a rendering bug.
switchCharset must reset prevStyled for obvious reasons (it refers to
a dead document).
Diffstat (limited to 'src')
| -rw-r--r-- | src/local/container.nim | 12 | ||||
| -rw-r--r-- | src/server/buffer.nim | 8 |
2 files changed, 8 insertions, 12 deletions
diff --git a/src/local/container.nim b/src/local/container.nim index ef14a303..c4427ec6 100644 --- a/src/local/container.nim +++ b/src/local/container.nim @@ -1466,9 +1466,7 @@ proc readSuccess*(container: Container, s: string) = container.triggerEvent(ContainerEvent(t: OPEN, request: res.open.get))) proc reshape(container: Container): EmptyPromise {.jsfunc.} = - return container.iface.render().then(proc(lines: int): auto = - container.setNumLines(lines) - container.triggerEvent(STATUS) + return container.iface.forceRender().then(proc(): EmptyPromise = return container.requestLines() ) @@ -1516,13 +1514,9 @@ proc windowChange*(container: Container, attrs: WindowAttributes) = if attrs.width != container.width or attrs.height - 1 != container.height: container.width = attrs.width container.height = attrs.height - 1 - container.iface.windowChange(attrs).then(proc(): auto = + container.iface.windowChange(attrs).then(proc() = container.needslines = true - return container.iface.render() - ).then(proc(lines: int) = - if lines != container.numLines: - container.setNumLines(lines, true) - container.needslines = true) + ) proc peek(container: Container) {.jsfunc.} = container.alert($container.location) diff --git a/src/server/buffer.nim b/src/server/buffer.nim index cfaa8b12..0b312517 100644 --- a/src/server/buffer.nim +++ b/src/server/buffer.nim @@ -59,7 +59,7 @@ import chame/tags type BufferCommand* = enum - LOAD, RENDER, WINDOW_CHANGE, FIND_ANCHOR, READ_SUCCESS, READ_CANCELED, + LOAD, FORCE_RENDER, WINDOW_CHANGE, FIND_ANCHOR, READ_SUCCESS, READ_CANCELED, CLICK, FIND_NEXT_LINK, FIND_PREV_LINK, FIND_NTH_LINK, FIND_REV_NTH_LINK, FIND_NEXT_MATCH, FIND_PREV_MATCH, GET_LINES, UPDATE_HOVER, CONNECT, CONNECT2, GOTO_ANCHOR, CANCEL, GET_TITLE, SELECT, REDIRECT_TO_FD, @@ -659,6 +659,7 @@ proc switchCharset(buffer: Buffer) = buffer.initDecoder() buffer.htmlParser.restart(buffer.charset) buffer.document = buffer.htmlParser.builder.document + buffer.prevStyled = nil const BufferSize = 16384 @@ -742,6 +743,7 @@ proc windowChange*(buffer: Buffer, attrs: WindowAttributes) {.proxy.} = buffer.prevStyled = nil if buffer.window != nil: buffer.window.attrs = attrs + buffer.do_reshape() type UpdateHoverResult* = object link*: Option[string] @@ -1207,9 +1209,9 @@ proc getTitle*(buffer: Buffer): string {.proxy.} = if buffer.document != nil: return buffer.document.title -proc render*(buffer: Buffer): int {.proxy.} = +proc forceRender*(buffer: Buffer) {.proxy.} = + buffer.prevStyled = nil buffer.do_reshape() - return buffer.lines.len proc cancel*(buffer: Buffer): int {.proxy.} = if buffer.state == bsLoaded: |