| 1 |
// +build linux darwin dragonfly solaris openbsd netbsd freebsd |
| 2 |
|
| 3 |
package terminal |
| 4 |
|
| 5 |
import ( |
| 6 |
"os" |
| 7 |
"syscall" |
| 8 |
"unsafe" |
| 9 |
) |
| 10 |
|
| 11 |
func ioctl(f *os.File, cmd, p uintptr) error { |
| 12 |
_, _, errno := syscall.Syscall( |
| 13 |
syscall.SYS_IOCTL, |
| 14 |
f.Fd(), |
| 15 |
syscall.TIOCSWINSZ, |
| 16 |
p) |
| 17 |
if errno != 0 { |
| 18 |
return syscall.Errno(errno) |
| 19 |
} |
| 20 |
return nil |
| 21 |
} |
| 22 |
|
| 23 |
func (t *VT) ptyResize() error { |
| 24 |
if t.pty == nil { |
| 25 |
return nil |
| 26 |
} |
| 27 |
var w struct{ row, col, xpix, ypix uint16 } |
| 28 |
w.row = uint16(t.dest.rows) |
| 29 |
w.col = uint16(t.dest.cols) |
| 30 |
w.xpix = 16 * uint16(t.dest.cols) |
| 31 |
w.ypix = 16 * uint16(t.dest.rows) |
| 32 |
return ioctl(t.pty, syscall.TIOCSWINSZ, |
| 33 |
uintptr(unsafe.Pointer(&w))) |
| 34 |
} |