| 37 | 37 |
boolCh chan bool
|
| 38 | 38 |
frameReaderCh chan *frameReader
|
| 39 | 39 |
syncTableCh chan [][]chan int
|
| 40 | |
bufNL *bytes.Buffer
|
| 41 | 40 |
|
| 42 | 41 |
// done is closed by Bar's goroutine, after cacheState is written
|
| 43 | 42 |
done chan struct{}
|
|
| 64 | 63 |
shutdownListeners []decor.ShutdownListener
|
| 65 | 64 |
refill *refill
|
| 66 | 65 |
bufP, bufB, bufA *bytes.Buffer
|
|
66 |
bufNL *bytes.Buffer
|
| 67 | 67 |
panicMsg string
|
| 68 | 68 |
newLineExtendFn func(io.Writer, *decor.Statistics)
|
| 69 | 69 |
|
|
| 77 | 77 |
}
|
| 78 | 78 |
frameReader struct {
|
| 79 | 79 |
io.Reader
|
|
80 |
extendedLines int
|
| 80 | 81 |
toShutdown bool
|
| 81 | 82 |
removeOnComplete bool
|
| 82 | 83 |
}
|
|
| 120 | 121 |
}
|
| 121 | 122 |
|
| 122 | 123 |
if s.newLineExtendFn != nil {
|
| 123 | |
b.bufNL = bytes.NewBuffer(make([]byte, 0, s.width))
|
|
124 |
s.bufNL = bytes.NewBuffer(make([]byte, 0, s.width))
|
| 124 | 125 |
}
|
| 125 | 126 |
|
| 126 | 127 |
go b.serve(wg, s, cancel)
|
|
| 282 | 283 |
}
|
| 283 | 284 |
}()
|
| 284 | 285 |
r := s.draw(tw)
|
|
286 |
var extendedLines int
|
| 285 | 287 |
if s.newLineExtendFn != nil {
|
| 286 | |
b.bufNL.Reset()
|
| 287 | |
s.newLineExtendFn(b.bufNL, newStatistics(s))
|
| 288 | |
r = io.MultiReader(r, b.bufNL)
|
|
288 |
s.bufNL.Reset()
|
|
289 |
s.newLineExtendFn(s.bufNL, newStatistics(s))
|
|
290 |
extendedLines = countLines(s.bufNL.Bytes())
|
|
291 |
r = io.MultiReader(r, s.bufNL)
|
| 289 | 292 |
}
|
| 290 | 293 |
b.frameReaderCh <- &frameReader{
|
| 291 | 294 |
Reader: r,
|
|
295 |
extendedLines: extendedLines,
|
| 292 | 296 |
toShutdown: s.toComplete && !s.completeFlushed,
|
| 293 | 297 |
removeOnComplete: s.removeOnComplete,
|
| 294 | 298 |
}
|
|
| 297 | 301 |
case <-b.done:
|
| 298 | 302 |
s := b.cacheState
|
| 299 | 303 |
r := s.draw(tw)
|
|
304 |
var extendedLines int
|
| 300 | 305 |
if s.newLineExtendFn != nil {
|
| 301 | |
b.bufNL.Reset()
|
| 302 | |
s.newLineExtendFn(b.bufNL, newStatistics(s))
|
| 303 | |
r = io.MultiReader(r, b.bufNL)
|
| 304 | |
}
|
| 305 | |
b.frameReaderCh <- &frameReader{Reader: r}
|
|
306 |
s.bufNL.Reset()
|
|
307 |
s.newLineExtendFn(s.bufNL, newStatistics(s))
|
|
308 |
extendedLines = countLines(s.bufNL.Bytes())
|
|
309 |
r = io.MultiReader(r, s.bufNL)
|
|
310 |
}
|
|
311 |
b.frameReaderCh <- &frameReader{
|
|
312 |
Reader: r,
|
|
313 |
extendedLines: extendedLines,
|
|
314 |
}
|
| 306 | 315 |
}
|
| 307 | 316 |
}
|
| 308 | 317 |
|
|
| 434 | 443 |
}
|
| 435 | 444 |
return
|
| 436 | 445 |
}
|
|
446 |
|
|
447 |
func countLines(b []byte) int {
|
|
448 |
return bytes.Count(b, []byte("\n"))
|
|
449 |
}
|