Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace Syscall with x/sys/unix.IoctlSetWinsize #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@ module github.com/zyedidia/terminal

go 1.19

require github.com/creack/pty v1.1.18
require (
github.com/creack/pty v1.1.18
golang.org/x/sys v0.28.0
)
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY=
github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
10 changes: 1 addition & 9 deletions ioctl_other.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
// +build plan9 nacl windows
//go:build plan9 || nacl || windows

package terminal

import (
"os"
)

func ioctl(f *os.File, cmd, p uintptr) error {
return nil
}

func (t *VT) ptyResize() error {
return nil
}
32 changes: 9 additions & 23 deletions ioctl_posix.go
Original file line number Diff line number Diff line change
@@ -1,34 +1,20 @@
// +build linux darwin dragonfly solaris openbsd netbsd freebsd
//go:build linux || darwin || dragonfly || solaris || openbsd || netbsd || freebsd

package terminal

import (
"os"
"syscall"
"unsafe"
"golang.org/x/sys/unix"
)

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)))
w := &unix.Winsize{
Row: uint16(t.dest.rows),
Col: uint16(t.dest.cols),
Xpixel: 16 * uint16(t.dest.cols),
Ypixel: 16 * uint16(t.dest.rows),
}
return unix.IoctlSetWinsize(int(t.pty.Fd()), unix.TIOCSWINSZ, w)
}
1 change: 0 additions & 1 deletion vt_other.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build plan9 || nacl || windows
// +build plan9 nacl windows

package terminal

Expand Down
1 change: 0 additions & 1 deletion vt_posix.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build linux || darwin || dragonfly || solaris || openbsd || netbsd || freebsd
// +build linux darwin dragonfly solaris openbsd netbsd freebsd

package terminal

Expand Down