Skip to content
Myr

Simplify LightRenderer.Size()

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Junegunn Choi · committed by Junegunn Choi · parent b1a0ab8 · Browse files · 1 file+4 added−12 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+4 added−12 removed

  • other:+4 added−12 removed

1 file+4 added−12 removed

modified:src/tui/light_unix.go+4 added-12 removed
6 unmodified lines
7 "os"8 "os/exec"9 "strings"10 "syscall"11 "unsafe"1112 "github.com/junegunn/fzf/src/util"13 "golang.org/x/sys/unix"14 "golang.org/x/term"15)1617func IsLightRendererSupported() bool {
91 unmodified lines
109 }110 return int(b[0]), true111}112113type window struct {114 lines uint16115 columns uint16116 width uint16117 height uint16118}119113func (r *LightRenderer) Size() (termSize, error) {121 w := new(window)122 _, _, err := syscall.Syscall(syscall.SYS_IOCTL, r.ttyin.Fd(), syscall.TIOCGWINSZ, uintptr(unsafe.Pointer(w)))123 if err != 0 {114 ws, err := unix.IoctlGetWinsize(int(r.ttyin.Fd()), unix.TIOCGWINSZ)115 if err != nil {116 return termSize{}, err117 }126 return termSize{int(w.lines), int(w.columns), int(w.width), int(w.height)}, nil118 return termSize{int(ws.Row), int(ws.Col), int(ws.Xpixel), int(ws.Ypixel)}, nil119}