github.com/dolfly/pty@v1.2.1/winsize_unix.go (about)

     1  //go:build !windows
     2  //+build !windows
     3  
     4  package pty
     5  
     6  import (
     7  	"syscall"
     8  	"unsafe"
     9  )
    10  
    11  // Setsize resizes t to s.
    12  func Setsize(t FdHolder, ws *Winsize) error {
    13  	//nolint:gosec // Expected unsafe pointer for Syscall call.
    14  	return ioctl(t.Fd(), syscall.TIOCSWINSZ, uintptr(unsafe.Pointer(ws)))
    15  }
    16  
    17  // GetsizeFull returns the full terminal size description.
    18  func GetsizeFull(t FdHolder) (size *Winsize, err error) {
    19  	var ws Winsize
    20  
    21  	//nolint:gosec // Expected unsafe pointer for Syscall call.
    22  	if err := ioctl(t.Fd(), syscall.TIOCGWINSZ, uintptr(unsafe.Pointer(&ws))); err != nil {
    23  		return nil, err
    24  	}
    25  	return &ws, nil
    26  }