From de2a1e6b245f573772d2c69d403271db8ceae2fe Mon Sep 17 00:00:00 2001 From: bptato Date: Fri, 15 Dec 2023 02:25:02 +0100 Subject: container: track ishtml status This way we can at least view HTML source of x-htmloutput filtered buffers. TODO: make it render the actual source instead. --- src/local/container.nim | 3 +++ src/local/pager.nim | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/local/container.nim b/src/local/container.nim index 8a0ae37e..8874c2d0 100644 --- a/src/local/container.nim +++ b/src/local/container.nim @@ -120,6 +120,7 @@ type tmpJumpMark: PagePos jumpMark: PagePos marks: Table[string, PagePos] + ishtml*: bool jsDestructor(Highlight) jsDestructor(Container) @@ -1200,6 +1201,7 @@ proc load(container: Container) = "application/octet-stream", container.config.mimeTypes) if contentType != "application/octet-stream": container.iface.setContentType(contentType) + container.ishtml = contentType == "text/html" container.source.contentType = some(contentType) else: container.source.contentType = some(res.contentType) @@ -1225,6 +1227,7 @@ proc redirectToFd*(container: Container, fdin: FileHandle, wait: bool): proc readFromFd*(container: Container, fdout: FileHandle, ishtml: bool): EmptyPromise = + container.ishtml = ishtml return container.iface.readFromFd(fdout, ishtml) proc quit*(container: Container) = diff --git a/src/local/pager.nim b/src/local/pager.nim index a6a4d77b..ab250986 100644 --- a/src/local/pager.nim +++ b/src/local/pager.nim @@ -619,7 +619,7 @@ proc toggleSource(pager: Pager) {.jsfunc.} = if pager.container.sourcepair != nil: pager.setContainer(pager.container.sourcepair) else: - let contentType = if pager.container.contentType.get("") == "text/html": + let contentType = if pager.container.ishtml: "text/plain" else: "text/html" -- cgit 1.4.1-2-gfad0