File: ioctl_posix.go

package info (click to toggle)
golang-github-zyedidia-terminal 0.0~git20230315.4b3bcf6-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 148 kB
  • sloc: makefile: 3
file content (34 lines) | stat: -rw-r--r-- 640 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// +build linux darwin dragonfly solaris openbsd netbsd freebsd

package terminal

import (
	"os"
	"syscall"
	"unsafe"
)

func ioctl(f *os.File, cmd, p uintptr) error {
	_, _, errno := syscall.Syscall(
		syscall.SYS_IOCTL,
		f.Fd(),
		syscall.TIOCSWINSZ,
		p)
	if errno != 0 {
		return syscall.Errno(errno)
	}
	return nil
}

func (t *VT) ptyResize() error {
	if t.pty == nil {
		return nil
	}
	var w struct{ row, col, xpix, ypix uint16 }
	w.row = uint16(t.dest.rows)
	w.col = uint16(t.dest.cols)
	w.xpix = 16 * uint16(t.dest.cols)
	w.ypix = 16 * uint16(t.dest.rows)
	return ioctl(t.pty, syscall.TIOCSWINSZ,
		uintptr(unsafe.Pointer(&w)))
}