Add extension to github.com/kr/pty

This commit is contained in:
Marcin Kulik
2014-08-02 22:25:54 +02:00
parent 16bb6fb016
commit 41c8b0d198

31
ptyx/size.go Normal file
View File

@@ -0,0 +1,31 @@
package ptyx
// Extension to github.com/kr/pty adding Setsize()
import (
"os"
"syscall"
"unsafe"
)
type winsize struct {
ws_row uint16
ws_col uint16
ws_xpixel uint16
ws_ypixel uint16
}
func ioctl(fd, cmd, ptr uintptr) error {
_, _, e := syscall.Syscall(syscall.SYS_IOCTL, fd, cmd, ptr)
if e != 0 {
return e
}
return nil
}
func Setsize(f *os.File, rows int, cols int) error {
var ws winsize
ws.ws_row = uint16(rows)
ws.ws_col = uint16(cols)
return ioctl(f.Fd(), syscall.TIOCSWINSZ, uintptr(unsafe.Pointer(&ws)))
}