about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--doc/config.md10
-rw-r--r--res/config.toml1
-rw-r--r--src/config/config.nim1
-rw-r--r--src/local/client.nim5
-rw-r--r--src/local/pager.nim2
5 files changed, 16 insertions, 3 deletions
diff --git a/doc/config.md b/doc/config.md
index 854c4848..ef23c440 100644
--- a/doc/config.md
+++ b/doc/config.md
@@ -88,6 +88,16 @@ do not block loading.)</td>
 enabled when Chawan is called with -r.</td>
 </tr>
 
+<tr>
+<td>console-buffer</td>
+<td>boolean</td>
+<td>Whether Chawan should open a console buffer in non-headless mode. Defaults
+to true.<br>
+Warning: this is only useful for debugging. Disabling this option without
+manually redirecting standard error will result in error messages randomly
+appearing on your screen.</td>
+</tr>
+
 </table>
 
 ## Search
diff --git a/res/config.toml b/res/config.toml
index c9cc7c09..d421ed8d 100644
--- a/res/config.toml
+++ b/res/config.toml
@@ -2,6 +2,7 @@
 visual-home = "about:chawan"
 startup-script = ""
 headless = false
+console-buffer = true
 
 [search]
 wrap = true
diff --git a/src/config/config.nim b/src/config/config.nim
index 912c35e6..8f798cd3 100644
--- a/src/config/config.nim
+++ b/src/config/config.nim
@@ -72,6 +72,7 @@ type
     visual_home* {.jsgetset.}: string
     startup_script* {.jsgetset.}: string
     headless* {.jsgetset.}: bool
+    console_buffer* {.jsgetset.}: bool
 
   CSSConfig = object
     stylesheet* {.jsgetset.}: string
diff --git a/src/local/client.nim b/src/local/client.nim
index 2c5963aa..87defeb4 100644
--- a/src/local/client.nim
+++ b/src/local/client.nim
@@ -153,7 +153,8 @@ proc command0(client: Client, src: string, filename = "<command>",
 proc command(client: Client, src: string) =
   client.command0(src)
   let container = client.consoleWrapper.container
-  container.tailOnLoad = true
+  if container != nil:
+    container.tailOnLoad = true
 
 proc suspend(client: Client) {.jsfunc.} =
   client.pager.term.quit()
@@ -715,7 +716,7 @@ const ConsoleTitle = "Browser Console"
 
 proc addConsole(pager: Pager; interactive: bool; clearFun, showFun, hideFun:
     proc()): ConsoleWrapper =
-  if interactive:
+  if interactive and pager.config.start.console_buffer:
     var pipefd: array[0..1, cint]
     if pipe(pipefd) == -1:
       raise newException(Defect, "Failed to open console pipe.")
diff --git a/src/local/pager.nim b/src/local/pager.nim
index d4c02bca..5dbb8ae0 100644
--- a/src/local/pager.nim
+++ b/src/local/pager.nim
@@ -88,7 +88,7 @@ type
     askprompt: string
     cgiDir*: seq[string]
     commandMode {.jsget.}: bool
-    config: Config
+    config*: Config
     connectingContainers*: seq[ConnectingContainerItem]
     container*: Container
     cookiejars: Table[string, CookieJar]