about summary refs log tree commit diff stats
path: root/src/display/client.nim
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2022-12-10 23:52:31 +0100
committerbptato <nincsnevem662@gmail.com>2022-12-10 23:52:31 +0100
commit3d6767aeca9393238aaaceccac4f292553bb3dc2 (patch)
tree64e898c9bba4e1a05d4792a195dd720db8ffe8d3 /src/display/client.nim
parent940325abfc9714b06de920a2a7f8911eae22f357 (diff)
downloadchawan-3d6767aeca9393238aaaceccac4f292553bb3dc2.tar.gz
Fix -d
Diffstat (limited to 'src/display/client.nim')
-rw-r--r--src/display/client.nim27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/display/client.nim b/src/display/client.nim
index e696457c..7bf9a278 100644
--- a/src/display/client.nim
+++ b/src/display/client.nim
@@ -313,6 +313,32 @@ proc inputLoop(client: Client) =
     client.pager.draw()
     client.acceptBuffers()
 
+proc dumpLoop(client: Client) =
+  while client.pager.numload > 0:
+    let events = client.selector.select(-1)
+    for event in events:
+      if Read in event.events:
+        let container = client.fdmap[event.fd]
+        if not client.pager.handleEvent(container):
+          client.quit(1)
+      if Error in event.events:
+        #TODO handle errors
+        client.alert("Error in selected fds, check console")
+        client.console.log($event)
+      if Event.Timer in event.events:
+        if event.fd in client.interval_fdis:
+          client.intervals[client.interval_fdis[event.fd]].handler()
+        elif event.fd in client.timeout_fdis:
+          let id = client.timeout_fdis[event.fd]
+          let timeout = client.timeouts[id]
+          timeout.handler()
+          client.clearTimeout(id)
+    if client.pager.scommand != "":
+      client.command(client.pager.scommand)
+      client.pager.scommand = ""
+      client.pager.refreshStatusMsg()
+    client.acceptBuffers()
+
 proc headlessLoop(client: Client) =
   while client.timeouts.len + client.intervals.len != 0:
     let events = client.selector.select(-1)
@@ -366,6 +392,7 @@ proc newConsole(pager: Pager, tty: File): Console =
     result.err = newFileStream(stderr)
 
 proc dumpBuffers(client: Client) =
+  client.dumpLoop()
   let ostream = newFileStream(stdout)
   for container in client.pager.containers:
     client.pager.drawBuffer(container, ostream)