Skip to content

Commit 28b1785

Browse files
committed
Replace Syscall with x/sys/unix.IoctlSetWinsize
1 parent 4be3967 commit 28b1785

File tree

3 files changed

+14
-23
lines changed

3 files changed

+14
-23
lines changed

go.mod

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,7 @@ module github.com/zyedidia/terminal
22

33
go 1.19
44

5-
require github.com/creack/pty v1.1.18
5+
require (
6+
github.com/creack/pty v1.1.18
7+
golang.org/x/sys v0.28.0
8+
)

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY=
22
github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
3+
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
4+
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=

ioctl_posix.go

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,18 @@
33
package terminal
44

55
import (
6-
"os"
7-
"syscall"
8-
"unsafe"
6+
"golang.org/x/sys/unix"
97
)
108

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-
239
func (t *VT) ptyResize() error {
2410
if t.pty == nil {
2511
return nil
2612
}
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)))
13+
w := &unix.Winsize{
14+
Row: uint16(t.dest.rows),
15+
Col: uint16(t.dest.cols),
16+
Xpixel: 16 * uint16(t.dest.cols),
17+
Ypixel: 16 * uint16(t.dest.rows),
18+
}
19+
return unix.IoctlSetWinsize(int(t.pty.Fd()), unix.TIOCSWINSZ, w)
3420
}

0 commit comments

Comments
 (0)