Going to use minio/pb forked version as primary, since we might make more changes in future.

While we submit all our changes upstream
This commit is contained in:
Harshavardhana
2015-07-05 01:16:51 -07:00
parent 072106ec30
commit 12680b6fbf
17 changed files with 16 additions and 10 deletions
+4
View File
@@ -0,0 +1,4 @@
language: go
go:
- 1.4.2
sudo: false
@@ -13,7 +13,7 @@ func main() {
bar.ShowPercent = true
// show bar (by default already true)
bar.ShowPercent = true
bar.ShowBar = true
// no need counters
bar.ShowCounters = true
@@ -8,6 +8,7 @@ import (
"sync"
"sync/atomic"
"time"
"unicode/utf8"
)
const (
@@ -267,9 +268,10 @@ func (pb *ProgressBar) write(current int64) {
speedBox = Format(int64(speed), pb.Units) + "/s "
}
barWidth := utf8.RuneCountInString(countersBox + pb.BarStart + pb.BarEnd + percentBox + timeLeftBox + speedBox + pb.prefix + pb.postfix)
// bar
if pb.ShowBar {
size := width - len(countersBox+pb.BarStart+pb.BarEnd+percentBox+timeLeftBox+speedBox+pb.prefix+pb.postfix)
size := width - barWidth
if size > 0 {
if pb.Total > 0 {
curCount := int(math.Ceil((float64(current) / float64(pb.Total)) * float64(size)))
@@ -306,8 +308,8 @@ func (pb *ProgressBar) write(current int64) {
// check len
out = pb.prefix + countersBox + barBox + percentBox + speedBox + timeLeftBox + pb.postfix
if len(out) < width {
end = strings.Repeat(" ", width-len(out))
if utf8.RuneCountInString(out) < width {
end = strings.Repeat(" ", width-utf8.RuneCountInString(out))
}
// and print!