summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/tui/light.go3
-rw-r--r--src/util/util_unix.go5
-rw-r--r--src/util/util_windows.go5
3 files changed, 12 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
}
diff --git a/src/util/util_unix.go b/src/util/util_unix.go
index bc1b7b52..d538ee00 100644
--- a/src/util/util_unix.go
+++ b/src/util/util_unix.go
@@ -26,3 +26,8 @@ func IsWindows() bool {
func SetNonblock(file *os.File, nonblock bool) {
syscall.SetNonblock(int(file.Fd()), nonblock)
}
+
+// Read executes syscall.Read on file descriptor
+func Read(fd int, b []byte) (int, error) {
+ return syscall.Read(int(fd), b)
+}
diff --git a/src/util/util_windows.go b/src/util/util_windows.go
index 9ba4f79e..06644167 100644
--- a/src/util/util_windows.go
+++ b/src/util/util_windows.go
@@ -32,3 +32,8 @@ func IsWindows() bool {
func SetNonblock(file *os.File, nonblock bool) {
syscall.SetNonblock(syscall.Handle(file.Fd()), nonblock)
}
+
+// Read executes syscall.Read on file descriptor
+func Read(fd int, b []byte) (int, error) {
+ return syscall.Read(syscall.Handle(fd), b)
+}