fix(prog): try to fix tracker length resize

This commit is contained in:
iyear 2023-12-04 10:49:44 +08:00
parent 94406e9185
commit 2172f40437

View File

@ -14,15 +14,13 @@ func New(formatter progress.UnitsFormatter) progress.Writer {
pw := progress.NewWriter()
pw.SetAutoStop(false)
width := 50
width := 100
if size, err := tsize.GetSize(); err == nil {
width = size.Width
}
if width > 100 {
width = 100
}
pw.SetTrackerLength(width / 3)
pw.SetMessageWidth(width * 2 / 3)
width -= 50 // tail length
pw.SetTrackerLength(width / 5)
pw.SetMessageWidth(width * 3 / 5)
pw.SetStyle(progress.StyleDefault)
pw.SetTrackerPosition(progress.PositionRight)
pw.SetUpdateFrequency(time.Millisecond * 100)