No need to check bar's complete rune
Vladimir Bauer
8 years ago
| 303 | 303 | close(ch) |
| 304 | 304 | }() |
| 305 | 305 | s.draw(tw, prependWs, appendWs) |
| 306 | ch <- &writeBuf{s.toBytes(), s.isFull()} | |
| 306 | ch <- &writeBuf{s.toBytes(), s.completed} | |
| 307 | 307 | }: |
| 308 | 308 | case <-b.done: |
| 309 | 309 | s := b.cacheState |
| 335 | 335 | s.blockStartTime = next |
| 336 | 336 | } |
| 337 | 337 | |
| 338 | func (s *state) isFull() bool { | |
| 339 | if !s.completed { | |
| 340 | return false | |
| 341 | } | |
| 342 | bar := s.bufB.Bytes() | |
| 343 | var r rune | |
| 344 | var n int | |
| 345 | for i := 0; len(bar) > 0; i++ { | |
| 346 | r, n = utf8.DecodeLastRune(bar) | |
| 347 | bar = bar[:len(bar)-n] | |
| 348 | if i == 1 { | |
| 349 | break | |
| 350 | } | |
| 351 | } | |
| 352 | return r == s.format[rFill] | |
| 353 | } | |
| 354 | ||
| 355 | 338 | func (s *state) draw(termWidth int, prependWs, appendWs *widthSync) { |
| 356 | 339 | if termWidth <= 0 { |
| 357 | 340 | termWidth = 2 |