Codebase list golang-github-vbauerster-mpb / 0f938df
AppendETA Vladimir Bauer 9 years ago
1 changed file(s) with 4 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
113113 func (b *Bar) AppendETA() *Bar {
114114 b.AppendFunc(func(s *Statistics) string {
115115 eta := time.Duration(s.Total-s.Completed) * s.TimePerItemEstimate
116 return fmt.Sprint(time.Duration(eta.Seconds()) * time.Second)
116 return fmt.Sprintf("ETA %v", time.Duration(eta.Seconds())*time.Second)
117117 })
118118 return b
119119 }
128128 func (b *Bar) server() {
129129 var current int
130130 blockStartTime := time.Now()
131 buf := make([]byte, b.Width, b.Width+9)
131 buf := make([]byte, b.Width, b.Width+24)
132132 var appendFuncs []DecoratorFunc
133133 var prependFuncs []DecoratorFunc
134134 for {
149149 prependFuncs = append(prependFuncs, d.f)
150150 }
151151 case r := <-b.redrawRequestCh:
152 r.bufch <- b.draw(buf, current, appendFuncs)
152 r.bufch <- b.draw(buf, current, appendFuncs, prependFuncs)
153153 }
154154 }
155155 }
156156
157 func (b *Bar) draw(buf []byte, current int, appendFuncs []DecoratorFunc) []byte {
157 func (b *Bar) draw(buf []byte, current int, appendFuncs, prependFuncs []DecoratorFunc) []byte {
158158 completedWidth := current * b.Width / b.total
159159
160160 for i := 0; i < completedWidth; i++ {