| 385 | } |
| 386 | |
| 387 | func (w *ttyWriter) applyPadding(lines []lineData, terminalWidth int, timerLen int) { |
| 388 | var maxBeforeStatus int |
| 389 | for i := range lines { |
| 390 | l := &lines[i] |
| 391 | // Width before statusPad: space(1) + spinner(1) + prefix + space(1) + taskID + progress |
| 392 | beforeStatus := 3 + lenAnsi(l.prefix) + utf8.RuneCountInString(l.taskID) + lenAnsi(l.progress) |
| 393 | if beforeStatus > maxBeforeStatus { |
| 394 | maxBeforeStatus = beforeStatus |
| 395 | } |
| 396 | } |
| 397 | |
| 398 | for i, l := range lines { |
| 399 | // Position before statusPad: space(1) + spinner(1) + prefix + space(1) + taskID + progress |
| 400 | beforeStatus := 3 + lenAnsi(l.prefix) + utf8.RuneCountInString(l.taskID) + lenAnsi(l.progress) |
| 401 | // statusPad aligns status; lineText adds 1 more space after statusPad |
| 402 | l.statusPad = maxBeforeStatus - beforeStatus |
| 403 | |
| 404 | // Format: beforeStatus + statusPad + space(1) + status |
| 405 | lineLen := beforeStatus + l.statusPad + 1 + utf8.RuneCountInString(l.status) |
| 406 | if l.details != "" { |
| 407 | lineLen += 1 + utf8.RuneCountInString(l.details) |
| 408 | } |
| 409 | l.timerPad = max(terminalWidth-lineLen-timerLen, 1) |
| 410 | lines[i] = l |
| 411 | |
| 412 | } |
| 413 | } |
| 414 | |
| 415 | func (w *ttyWriter) adjustLineWidth(lines []lineData, timerLen int, terminalWidth int) { |
| 416 | const minIDLen = 10 |