From 44451ed4505c4a38d8763ad4736aeaacbaeef4de Mon Sep 17 00:00:00 2001 From: bptato Date: Mon, 18 Mar 2024 21:27:07 +0100 Subject: client: refactor input * move mouse handling to term * do not use File for input just to disable buffering anyway --- src/io/posixstream.nim | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/io') 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) -- cgit 1.4.1-2-gfad0