tinybox
Owner: IIIlllIIIllI URL: git@github.com:nyangkosense/tinybox.git
syscall.Select now returns only the count
Commit 5cc090d78842017105d9707b1c1fd16e29aa247c by SM <seb.michalk@gmail.com> on 2025-09-24 10:13:10 +0200
diff --git a/tinybox/tb.go b/tinybox/tb.go
index 4010303..22535c2 100644
--- a/tinybox/tb.go
+++ b/tinybox/tb.go
@@ -291,9 +291,9 @@ func queryTermSize() (int, int, error) {
fdSet.Bits[fd/64] |= 1 << (uint(fd) % 64)
tv := syscall.Timeval{Sec: 1, Usec: 0}
- n, err := syscall.Select(fd+1, fdSet, nil, nil, &tv)
- if err != nil || n == 0 {
- return 80, 24, fmt.Errorf("terminal size query timeout")
+ n := syscall.Select(fd+1, fdSet, nil, nil, &tv)
+ if n <= 0 {
+ return 80, 24, fmt.Errorf("timeout")
}
n, err = syscall.Read(syscall.Stdin, buf[:])
@@ -679,11 +679,8 @@ func PollEventTimeout(timeout time.Duration) (Event, error) {
Usec: int64((timeout % time.Second) / time.Microsecond),
}
- n, err := syscall.Select(fd+1, fdSet, nil, nil, &tv)
- if err != nil {
- return Event{}, err
- }
- if n == 0 {
+ n := syscall.Select(fd+1, fdSet, nil, nil, &tv)
+ if n <= 0 {
return Event{}, fmt.Errorf("timeout")
}
@@ -1077,8 +1074,8 @@ func GetCursorPos() (x, y int) {
fdSet.Bits[fd/64] |= 1 << (uint(fd) % 64)
tv := syscall.Timeval{Sec: 1, Usec: 0} // 1 second timeout
- n, err := syscall.Select(fd+1, fdSet, nil, nil, &tv)
- if err != nil || n == 0 {
+ n := syscall.Select(fd+1, fdSet, nil, nil, &tv)
+ if n <= 0 {
return 0, 0
}