Skip to content

Commit

Permalink
Open /dev/tty in non-blocking mode
Browse files Browse the repository at this point in the history
Resolves gdamore#452.
  • Loading branch information
tslocum authored and zyedidia committed Feb 12, 2024
1 parent 718ffbd commit b11bd6e
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion tscreen.go
Expand Up @@ -1668,14 +1668,23 @@ func (t *tScreen) mainLoop(stopQ chan struct{}) {
}

func (t *tScreen) inputLoop(stopQ chan struct{}) {

defer t.wg.Done()
var (
n int
err error
)
for {
select {
case <-stopQ:
return
default:
}

err = t.in.SetReadDeadline(time.Now().Add(250 * time.Millisecond))
if err != nil {
panic(err)
}

chunk := make([]byte, 128)
n, e := t.tty.Read(chunk)
switch e {
Expand Down

0 comments on commit b11bd6e

Please sign in to comment.