mirror of
https://github.com/Llewellynvdm/fzf.git
synced 2024-12-22 19:09:00 +00:00
Simplify LightRenderer.Size()
This commit is contained in:
parent
b1a0ab8086
commit
bac385b59c
@ -8,9 +8,9 @@ import (
|
||||
"os/exec"
|
||||
"strings"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
|
||||
"github.com/junegunn/fzf/src/util"
|
||||
"golang.org/x/sys/unix"
|
||||
"golang.org/x/term"
|
||||
)
|
||||
|
||||
@ -110,18 +110,10 @@ func (r *LightRenderer) getch(nonblock bool) (int, bool) {
|
||||
return int(b[0]), true
|
||||
}
|
||||
|
||||
type window struct {
|
||||
lines uint16
|
||||
columns uint16
|
||||
width uint16
|
||||
height uint16
|
||||
}
|
||||
|
||||
func (r *LightRenderer) Size() (termSize, error) {
|
||||
w := new(window)
|
||||
_, _, err := syscall.Syscall(syscall.SYS_IOCTL, r.ttyin.Fd(), syscall.TIOCGWINSZ, uintptr(unsafe.Pointer(w)))
|
||||
if err != 0 {
|
||||
ws, err := unix.IoctlGetWinsize(int(r.ttyin.Fd()), unix.TIOCGWINSZ)
|
||||
if err != nil {
|
||||
return termSize{}, err
|
||||
}
|
||||
return termSize{int(w.lines), int(w.columns), int(w.width), int(w.height)}, nil
|
||||
return termSize{int(ws.Row), int(ws.Col), int(ws.Xpixel), int(ws.Ypixel)}, nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user