mirror of
https://github.com/Llewellynvdm/fzf.git
synced 2025-01-09 09:50:26 +00:00
Simplify LightRenderer.Size()
This commit is contained in:
parent
b1a0ab8086
commit
bac385b59c
@ -8,9 +8,9 @@ import (
|
|||||||
"os/exec"
|
"os/exec"
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
"unsafe"
|
|
||||||
|
|
||||||
"github.com/junegunn/fzf/src/util"
|
"github.com/junegunn/fzf/src/util"
|
||||||
|
"golang.org/x/sys/unix"
|
||||||
"golang.org/x/term"
|
"golang.org/x/term"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -110,18 +110,10 @@ func (r *LightRenderer) getch(nonblock bool) (int, bool) {
|
|||||||
return int(b[0]), true
|
return int(b[0]), true
|
||||||
}
|
}
|
||||||
|
|
||||||
type window struct {
|
|
||||||
lines uint16
|
|
||||||
columns uint16
|
|
||||||
width uint16
|
|
||||||
height uint16
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *LightRenderer) Size() (termSize, error) {
|
func (r *LightRenderer) Size() (termSize, error) {
|
||||||
w := new(window)
|
ws, err := unix.IoctlGetWinsize(int(r.ttyin.Fd()), unix.TIOCGWINSZ)
|
||||||
_, _, err := syscall.Syscall(syscall.SYS_IOCTL, r.ttyin.Fd(), syscall.TIOCGWINSZ, uintptr(unsafe.Pointer(w)))
|
if err != nil {
|
||||||
if err != 0 {
|
|
||||||
return termSize{}, err
|
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