File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change
1
+ //go:build windows
1
2
// +build windows
2
3
3
4
package pb
@@ -24,7 +25,7 @@ func (p *Pool) print(first bool) bool {
24
25
}
25
26
coords .X = 0
26
27
27
- err = termutil .SetCursorPos (coords )
28
+ err = termutil .SetCursorPos (coords )
28
29
if err != nil {
29
30
log .Panic (err )
30
31
}
@@ -34,7 +35,11 @@ func (p *Pool) print(first bool) bool {
34
35
if ! bar .IsFinished () {
35
36
isFinished = false
36
37
}
37
- out += fmt .Sprintf ("\r %s\n " , bar .String ())
38
+ result := bar .String ()
39
+ if r := cols - CellCount (result ); r > 0 {
40
+ result += strings .Repeat (" " , r )
41
+ }
42
+ out += fmt .Sprintf ("\r %s\n " , result )
38
43
}
39
44
if p .Output != nil {
40
45
fmt .Fprint (p .Output , out )
Original file line number Diff line number Diff line change
1
+ //go:build linux || darwin || freebsd || netbsd || openbsd || solaris || dragonfly || plan9 || aix
1
2
// +build linux darwin freebsd netbsd openbsd solaris dragonfly plan9 aix
2
3
3
4
package pb
4
5
5
6
import (
6
7
"fmt"
7
8
"os"
9
+ "strings"
8
10
9
11
"github.com/cheggaaa/pb/v3/termutil"
10
12
)
@@ -31,7 +33,11 @@ func (p *Pool) print(first bool) bool {
31
33
isFinished = false
32
34
}
33
35
bar .SetWidth (cols )
34
- out += fmt .Sprintf ("\r %s\n " , bar .String ())
36
+ result := bar .String ()
37
+ if r := cols - CellCount (result ); r > 0 {
38
+ result += strings .Repeat (" " , r )
39
+ }
40
+ out += fmt .Sprintf ("\r %s\n " , result )
35
41
}
36
42
if p .Output != nil {
37
43
fmt .Fprint (p .Output , out )
You can’t perform that action at this time.
0 commit comments