diff options
Diffstat (limited to 'vendor/github.com/gdamore/tcell/v2/nonblock_bsd.go')
-rw-r--r-- | vendor/github.com/gdamore/tcell/v2/nonblock_bsd.go | 29 |
1 files changed, 10 insertions, 19 deletions
diff --git a/vendor/github.com/gdamore/tcell/v2/nonblock_bsd.go b/vendor/github.com/gdamore/tcell/v2/nonblock_bsd.go index df8fc0547..ffe5caf85 100644 --- a/vendor/github.com/gdamore/tcell/v2/nonblock_bsd.go +++ b/vendor/github.com/gdamore/tcell/v2/nonblock_bsd.go @@ -17,7 +17,6 @@ package tcell import ( - "os" "syscall" "golang.org/x/sys/unix" @@ -25,26 +24,18 @@ import ( // BSD systems use TIOC style ioctls. -// nonBlocking changes VMIN to 0, and VTIME to 1. This basically ensures that -// we can wake up the input loop. We only want to do this if we are going to interrupt -// that loop. Normally we use VMIN 1 and VTIME 0, which ensures we pick up bytes when -// they come but don't spin burning cycles. -func (t *tScreen) nonBlocking(on bool) { - fd := int(os.Stdin.Fd()) +// tcSetBufParams is used by the tty driver on UNIX systems to configure the +// buffering parameters (minimum character count and minimum wait time in msec.) +func tcSetBufParams(fd int, vMin uint8, vTime uint8) error { + _ = syscall.SetNonblock(fd, true) tio, err := unix.IoctlGetTermios(fd, unix.TIOCGETA) if err != nil { - return + return err } - if on { - tio.Cc[unix.VMIN] = 0 - tio.Cc[unix.VTIME] = 0 - } else { - // block for any output - tio.Cc[unix.VTIME] = 0 - tio.Cc[unix.VMIN] = 1 + tio.Cc[unix.VMIN] = vMin + tio.Cc[unix.VTIME] = vTime + if err = unix.IoctlSetTermios(fd, unix.TIOCSETA, tio); err != nil { + return err } - - _ = syscall.SetNonblock(fd, on) - // We want to set this *right now*. - _ = unix.IoctlSetTermios(fd, unix.TIOCSETA, tio) + return nil } |