Use golang.org/x/term for terminal width detection
Replace direct unix.IoctlGetWinsize() call with term.GetSize() for cleaner API. No binary size change as x/sys remains an indirect dependency.
This commit is contained in:
6
main.go
6
main.go
@ -11,7 +11,7 @@ import (
|
||||
|
||||
"github.com/go-git/go-git/v6"
|
||||
"github.com/shirou/gopsutil/v4/process"
|
||||
"golang.org/x/sys/unix"
|
||||
"golang.org/x/term"
|
||||
)
|
||||
|
||||
const statuslineWidthOffset = 7
|
||||
@ -197,11 +197,11 @@ func getGitInfo(cwd string) string {
|
||||
}
|
||||
|
||||
func getTerminalWidth() int {
|
||||
ws, err := unix.IoctlGetWinsize(int(os.Stdout.Fd()), unix.TIOCGWINSZ)
|
||||
width, _, err := term.GetSize(int(os.Stdout.Fd()))
|
||||
if err != nil {
|
||||
return 80
|
||||
}
|
||||
return int(ws.Col)
|
||||
return width
|
||||
}
|
||||
|
||||
var ansiRegex = regexp.MustCompile(`\x1b\[[0-9;]*m`)
|
||||
|
||||
Reference in New Issue
Block a user