about summary refs log tree commit diff stats
path: root/src/io
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-03-18 21:27:07 +0100
committerbptato <nincsnevem662@gmail.com>2024-03-18 21:27:07 +0100
commit44451ed4505c4a38d8763ad4736aeaacbaeef4de (patch)
tree190af134cb7a4e132810673bd67999e9fb736400 /src/io
parent50ee9b03e320628b73d511c7d5ae217b07f00cce (diff)
downloadchawan-44451ed4505c4a38d8763ad4736aeaacbaeef4de.tar.gz
client: refactor input
* move mouse handling to term
* do not use File for input just to disable buffering anyway
Diffstat (limited to 'src/io')
-rw-r--r--src/io/posixstream.nim10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/io/posixstream.nim b/src/io/posixstream.nim
index 911f384b..0b06c572 100644
--- a/src/io/posixstream.nim
+++ b/src/io/posixstream.nim
@@ -43,6 +43,16 @@ method recvData*(s: PosixStream, buffer: pointer, len: int): int =
     s.isend = true
   return n
 
+proc sreadChar*(s: PosixStream): char =
+  let n = read(s.fd, addr result, 1)
+  if n < 0:
+    raisePosixIOError()
+  if n == 0:
+    if unlikely(s.isend):
+      raise newException(EOFError, "eof")
+    s.isend = true
+  assert n == 1
+
 proc recvData*(s: PosixStream, buffer: var openArray[uint8]): int {.inline.} =
   return s.recvData(addr buffer[0], buffer.len)