mirror of
https://github.com/creack/pty.git
synced 2026-04-01 02:57:06 +09:00
Add pty.InheritSize for solaris support (#118)
This commit is contained in:
@@ -45,6 +45,21 @@ func Getsize(t *os.File) (rows, cols int, err error) {
|
||||
}
|
||||
}
|
||||
|
||||
// InheritSize applies the terminal size of pty to tty. This should be run
|
||||
// in a signal handler for syscall.SIGWINCH to automatically resize the tty when
|
||||
// the pty receives a window size change notification.
|
||||
func InheritSize(pty, tty *os.File) error {
|
||||
size, err := GetsizeFull(pty)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = Setsize(tty, size)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Setsize resizes t to s.
|
||||
func Setsize(t *os.File, ws *Winsize) error {
|
||||
wsz := unix.Winsize{ws.Rows, ws.Cols, ws.X, ws.Y}
|
||||
|
||||
Reference in New Issue
Block a user