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:
2025-12-18 18:36:54 +01:00
parent 58aaad4c9c
commit 0638707349
3 changed files with 5 additions and 11 deletions

View File

@ -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`)