diff options
author | bptato <nincsnevem662@gmail.com> | 2023-09-21 00:21:58 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2023-09-21 00:26:40 +0200 |
commit | 7c8cc5c20cb69f77204d6b19beed501c005bd3be (patch) | |
tree | 8dcf1bdfadce807f223141bb895243e00cb7adb2 | |
parent | a2d276c7b837359771a6fa68a6da07364aa98a3c (diff) | |
download | chawan-7c8cc5c20cb69f77204d6b19beed501c005bd3be.tar.gz |
Disable "toggle source" for the console buffer
-rw-r--r-- | src/local/client.nim | 3 | ||||
-rw-r--r-- | src/local/container.nim | 7 | ||||
-rw-r--r-- | src/local/pager.nim | 15 | ||||
-rw-r--r-- | todo | 1 |
4 files changed, 17 insertions, 9 deletions
diff --git a/src/local/client.nim b/src/local/client.nim index 70293d70..591e07c7 100644 --- a/src/local/client.nim +++ b/src/local/client.nim @@ -492,7 +492,8 @@ proc newConsole(pager: Pager, tty: File): Console = raise newException(Defect, "Failed to open console pipe.") let url = newURL("javascript:console.show()") result.container = pager.readPipe0(some("text/plain"), CHARSET_UNKNOWN, - pipefd[0], option(url.get(nil)), "Browser console") + pipefd[0], option(url.get(nil)), "Browser console", + canreinterpret = false) var f: File if not open(f, pipefd[1], fmWrite): raise newException(Defect, "Failed to open file for console pipe.") diff --git a/src/local/container.nim b/src/local/container.nim index 20c4865b..f8b6f1fc 100644 --- a/src/local/container.nim +++ b/src/local/container.nim @@ -97,11 +97,13 @@ type hasstart: bool redirectdepth*: int select*: Select + canreinterpret*: bool jsDestructor(Container) proc newBuffer*(forkserver: ForkServer, mainproc: Pid, config: BufferConfig, - source: BufferSource, title = "", redirectdepth = 0): Container = + source: BufferSource, title = "", redirectdepth = 0, + canreinterpret = true): Container = let attrs = getWindowAttributes(stdout) let ostream = forkserver.ostream let istream = forkserver.istream @@ -123,7 +125,8 @@ proc newBuffer*(forkserver: ForkServer, mainproc: Pid, config: BufferConfig, process: process, pos: CursorPosition( setx: -1 - ) + ), + canreinterpret: canreinterpret ) func charset*(container: Container): Charset = diff --git a/src/local/pager.nim b/src/local/pager.nim index 6c18c91c..26cbba53 100644 --- a/src/local/pager.nim +++ b/src/local/pager.nim @@ -395,14 +395,15 @@ proc addContainer*(pager: Pager, container: Container) = pager.setContainer(container) proc newBuffer(pager: Pager, bufferConfig: BufferConfig, source: BufferSource, - title = "", redirectdepth = 0): Container = + title = "", redirectdepth = 0, canreinterpret = true): Container = return newBuffer( pager.forkserver, pager.mainproc, bufferConfig, source, title, - redirectdepth + redirectdepth, + canreinterpret ) proc dupeBuffer(pager: Pager, container: Container, location: URL, @@ -550,6 +551,8 @@ proc discardTree(pager: Pager, container = none(Container)) {.jsfunc.} = pager.alert("Buffer has no children!") proc toggleSource(pager: Pager) {.jsfunc.} = + if not pager.container.canreinterpret: + return if pager.container.sourcepair != nil: pager.setContainer(pager.container.sourcepair) else: @@ -703,7 +706,8 @@ proc loadURL*(pager: Pager, url: string, ctype = none(string), pager.container.retry = urls proc readPipe0*(pager: Pager, ctype: Option[string], cs: Charset, - fd: FileHandle, location: Option[URL], title: string): Container = + fd: FileHandle, location: Option[URL], title: string, + canreinterpret: bool): Container = var location = location.get(newURL("file://-").get) let bufferconfig = pager.applySiteconf(location) let source = BufferSource( @@ -713,11 +717,12 @@ proc readPipe0*(pager: Pager, ctype: Option[string], cs: Charset, charset: cs, location: location ) - return pager.newBuffer(bufferconfig, source, title = title) + return pager.newBuffer(bufferconfig, source, title = title, + canreinterpret = canreinterpret) proc readPipe*(pager: Pager, ctype: Option[string], cs: Charset, fd: FileHandle) = - let container = pager.readPipe0(ctype, cs, fd, none(URL), "*pipe*") + let container = pager.readPipe0(ctype, cs, fd, none(URL), "*pipe*", true) pager.addContainer(container) proc command(pager: Pager) {.jsfunc.} = diff --git a/todo b/todo index 2f4a15ef..991214e1 100644 --- a/todo +++ b/todo @@ -33,7 +33,6 @@ buffer: - configurable/better url filtering in loader - make peekCursor show the entire url - buffer cloning: fork buffer process instead of piping source -- disable "reinterpret as html" for the log buffer - when the log buffer crashes, print its contents to stderr * make console.err a TeeStream, and tee it to a StringStream that buffers up to 4KB |