summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2023-10-23 23:40:56 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2023-10-23 23:40:56 +0900
commitbac385b59ccef279400689d406bf270cfdee06f3 (patch)
tree5104b5a8cb3f23a0307c7977d5fdc480b21bbcac
parentb1a0ab8086f061640948299b9ed90a6b0c61c143 (diff)
Simplify LightRenderer.Size()
-rw-r--r--src/tui/light_unix.go16
1 files changed, 4 insertions, 12 deletions
diff --git a/src/tui/light_unix.go b/src/tui/light_unix.go
index b9e433cc..4ca847b4 100644
--- a/src/tui/light_unix.go
+++ b/src/tui/light_unix.go
@@ -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
}