about summary refs log tree commit diff stats
path: root/src/display/client.nim
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-01-06 20:16:18 +0100
committerbptato <nincsnevem662@gmail.com>2023-01-06 22:24:01 +0100
commit8323cf214819297cae0ce0908e339a78a289434a (patch)
treea861b10713ae244ae593e8988087a8aa449a3375 /src/display/client.nim
parent85ec984f948623662a76a3fbfe50354f6be9612e (diff)
downloadchawan-8323cf214819297cae0ce0908e339a78a289434a.tar.gz
Slightly refactor commandMode
Diffstat (limited to 'src/display/client.nim')
-rw-r--r--src/display/client.nim16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/display/client.nim b/src/display/client.nim
index ecc01260..50d7383c 100644
--- a/src/display/client.nim
+++ b/src/display/client.nim
@@ -272,6 +272,9 @@ proc hide(console: Console) {.jsfunc.} =
   if console.pager.container == console.container:
     console.pager.setContainer(console.prev)
 
+proc buffer(console: Console): Container {.jsfget.} =
+  return console.container
+
 proc acceptBuffers(client: Client) =
   while client.pager.unreg.len > 0:
     let (pid, stream) = client.pager.unreg.pop()
@@ -307,17 +310,22 @@ proc handleRead(client: Client, fd: int) =
     client.input()
     client.handlePagerEvents()
   elif fd == client.dispatcher.forkserver.estream.fd:
-    var nl = true
+    var nl = false
+    const prefix = "STDERR: "
+    var s = prefix
     while true:
       try:
         let c = client.dispatcher.forkserver.estream.readChar()
-        if nl:
-          client.console.err.write("STDERR: ")
+        if nl and s.len > prefix.len:
+          client.console.err.write(s)
+          s = prefix
           nl = false
-        client.console.err.write(c)
+        s &= c
         nl = c == '\n'
       except IOError:
         break
+    if s.len > prefix.len:
+      client.console.err.write(s)
     client.console.err.flush()
   else:
     let container = client.fdmap[fd]