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 Jun 24, 2021
1 parent 1888c8a commit de9bf13
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion tscreen.go
Expand Up @@ -1534,14 +1534,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 de9bf13

Please sign in to comment.