Start work on proper TUI support

This commit is contained in:
Kovid Goyal
2022-08-23 18:53:55 +05:30
parent 67f03621ae
commit 3c3e7b7f70
7 changed files with 483 additions and 40 deletions

View File

@@ -12,20 +12,9 @@ import (
// Go unix does not wrap pselect on darwin
func Select(nfd int, r *unix.FdSet, w *unix.FdSet, e *unix.FdSet, timeout time.Duration) (n int, err error) {
deadline := time.Now().Add(timeout)
for {
t := deadline.Sub(time.Now())
if t < 0 {
t = 0
}
ts := NsecToTimeval(t)
q, qerr := unix.Select(nfd, r, w, w, &ts)
if qerr == unix.EINTR {
if time.Now().After(deadline) {
return 0, os.ErrDeadlineExceeded
}
continue
}
return q, qerr
if timeout < 0 {
return unix.Select(nfd, r, w, e, nil)
}
ts := NsecToTimeval(timeout)
return unix.Select(nfd, r, w, e, &ts)
}