mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-27 18:51:41 +02:00
Refactor tty code into its own package
This commit is contained in:
26
tools/tty/tty_bsd.go
Normal file
26
tools/tty/tty_bsd.go
Normal file
@@ -0,0 +1,26 @@
|
||||
//go:build darwin || freebsd || openbsd || netbsd || dragonfly
|
||||
// +build darwin freebsd openbsd netbsd dragonfly
|
||||
|
||||
package tty
|
||||
|
||||
import (
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
func Tcgetattr(fd uintptr, argp *unix.Termios) error {
|
||||
return unix.IoctlSetTermios(int(fd), unix.TIOCGETA, argp)
|
||||
}
|
||||
|
||||
func Tcsetattr(fd, opt uintptr, argp *unix.Termios) error {
|
||||
switch opt {
|
||||
case TCSANOW:
|
||||
opt = unix.TIOCSETA
|
||||
case TCSADRAIN:
|
||||
opt = unix.TIOCSETAW
|
||||
case TCSAFLUSH:
|
||||
opt = unix.TIOCSETAF
|
||||
default:
|
||||
return unix.EINVAL
|
||||
}
|
||||
return unix.IoctlSetTermios(int(fd), uint(opt), argp)
|
||||
}
|
||||
Reference in New Issue
Block a user