mirror of
https://github.com/asciinema/asciinema.git
synced 2025-12-16 11:48:13 +01:00
32 lines
541 B
Go
32 lines
541 B
Go
|
|
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)))
|
||
|
|
}
|