summaryrefslogtreecommitdiffstats
path: root/src/tui
diff options
context:
space:
mode:
authorTw <tw19881113@gmail.com>2017-05-24 11:36:59 -0500
committerJunegunn Choi <junegunn.c@gmail.com>2017-05-25 01:36:59 +0900
commitab182e276badc8222962f4d28a052dfa7f016d88 (patch)
tree1fba7fcf90fa01f5bb1f99fbfc5a285f023cf3db /src/tui
parent96a3250152749641edce8e91385ecf29dc2789a4 (diff)
Use read syscall directly to get character (#931)
Due to go std lib uses poller for os.File introducing in this commit: https://github.com/golang/go/commit/c05b06a12d005f50e4776095a60d6bd9c2c91fac There are two changes to watch out: 1. os.File.Fd will always return a blocking fd except on bsd. 2. os.File.Read won't return EAGAIN error for nonblocking fd. So For 1, we just get tty's fd in advance and then set its block mode. For 2, we use read syscall directly to get what we wanted error(EAGAIN). Fix issue #910. Signed-off-by: Tw <tw19881113@gmail.com>
Diffstat (limited to 'src/tui')
-rw-r--r--src/tui/light.go3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/tui/light.go b/src/tui/light.go
index be6950c8..e690ef9e 100644
--- a/src/tui/light.go
+++ b/src/tui/light.go
@@ -251,8 +251,9 @@ func (r *LightRenderer) updateTerminalSize() {
func (r *LightRenderer) getch(nonblock bool) (int, bool) {
b := make([]byte, 1)
+ fd := r.fd()
util.SetNonblock(r.ttyin, nonblock)
- _, err := r.ttyin.Read(b)
+ _, err := util.Read(fd, b)
if err != nil {
return 0, false
}