Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pool: fill line with spaces #208

Merged
merged 1 commit into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 7 additions & 2 deletions v3/pool_win.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build windows
// +build windows

package pb
Expand All @@ -24,7 +25,7 @@ func (p *Pool) print(first bool) bool {
}
coords.X = 0

err = termutil.SetCursorPos(coords)
err = termutil.SetCursorPos(coords)
if err != nil {
log.Panic(err)
}
Expand All @@ -34,7 +35,11 @@ func (p *Pool) print(first bool) bool {
if !bar.IsFinished() {
isFinished = false
}
out += fmt.Sprintf("\r%s\n", bar.String())
result := bar.String()
if r := cols - CellCount(result); r > 0 {
result += strings.Repeat(" ", r)
}
out += fmt.Sprintf("\r%s\n", result)
}
if p.Output != nil {
fmt.Fprint(p.Output, out)
Expand Down
8 changes: 7 additions & 1 deletion v3/pool_x.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
//go:build linux || darwin || freebsd || netbsd || openbsd || solaris || dragonfly || plan9 || aix
// +build linux darwin freebsd netbsd openbsd solaris dragonfly plan9 aix

package pb

import (
"fmt"
"os"
"strings"

"github.com/cheggaaa/pb/v3/termutil"
)
Expand All @@ -31,7 +33,11 @@ func (p *Pool) print(first bool) bool {
isFinished = false
}
bar.SetWidth(cols)
out += fmt.Sprintf("\r%s\n", bar.String())
result := bar.String()
if r := cols - CellCount(result); r > 0 {
result += strings.Repeat(" ", r)
}
out += fmt.Sprintf("\r%s\n", result)
}
if p.Output != nil {
fmt.Fprint(p.Output, out)
Expand Down