Skip to content

Commit

Permalink
Merge pull request #37 from thaJeztah/deprecate_termios
Browse files Browse the repository at this point in the history
deprecate Termios in favor of unix.Termios
  • Loading branch information
thaJeztah committed Apr 30, 2023
2 parents 1849d9c + 80ddd80 commit 0564e01
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions tc.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import (
"golang.org/x/sys/unix"
)

func tcget(fd uintptr) (*Termios, error) {
func tcget(fd uintptr) (*unix.Termios, error) {
p, err := unix.IoctlGetTermios(int(fd), getTermios)
if err != nil {
return nil, err
}
return p, nil
}

func tcset(fd uintptr, p *Termios) error {
func tcset(fd uintptr, p *unix.Termios) error {
return unix.IoctlSetTermios(int(fd), setTermios, p)
}
2 changes: 1 addition & 1 deletion term.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var ErrInvalidState = errors.New("Invalid terminal state")

// State represents the state of the terminal.
type State struct {
termios Termios
termios unix.Termios
}

// Winsize represents the size of the terminal window.
Expand Down
8 changes: 5 additions & 3 deletions termios.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
)

// Termios is the Unix API for terminal I/O.
//
// Deprecated: use [unix.Termios].
type Termios = unix.Termios

// MakeRaw puts the terminal connected to the given file descriptor into raw
Expand All @@ -21,10 +23,10 @@ func MakeRaw(fd uintptr) (*State, error) {

oldState := State{termios: *termios}

termios.Iflag &^= (unix.IGNBRK | unix.BRKINT | unix.PARMRK | unix.ISTRIP | unix.INLCR | unix.IGNCR | unix.ICRNL | unix.IXON)
termios.Iflag &^= unix.IGNBRK | unix.BRKINT | unix.PARMRK | unix.ISTRIP | unix.INLCR | unix.IGNCR | unix.ICRNL | unix.IXON
termios.Oflag &^= unix.OPOST
termios.Lflag &^= (unix.ECHO | unix.ECHONL | unix.ICANON | unix.ISIG | unix.IEXTEN)
termios.Cflag &^= (unix.CSIZE | unix.PARENB)
termios.Lflag &^= unix.ECHO | unix.ECHONL | unix.ICANON | unix.ISIG | unix.IEXTEN
termios.Cflag &^= unix.CSIZE | unix.PARENB
termios.Cflag |= unix.CS8
termios.Cc[unix.VMIN] = 1
termios.Cc[unix.VTIME] = 0
Expand Down

0 comments on commit 0564e01

Please sign in to comment.