MCPcopy
hub / github.com/docker/compose / adjustLineWidth

Method adjustLineWidth

cmd/display/tty.go:415–433  ·  cmd/display/tty.go::ttyWriter.adjustLineWidth
(lines []lineData, timerLen int, terminalWidth int)

Source from the content-addressed store, hash-verified

413}
414
415func (w *ttyWriter) adjustLineWidth(lines []lineData, timerLen int, terminalWidth int) {
416 const minIDLen = 10
417 maxStatusLen := maxStatusLength(lines)
418
419 // Iteratively truncate until all lines fit
420 for range 100 { // safety limit
421 maxBeforeStatus := maxBeforeStatusWidth(lines)
422 overflow := computeOverflow(lines, maxBeforeStatus, maxStatusLen, timerLen, terminalWidth)
423
424 if overflow <= 0 {
425 break
426 }
427
428 // Drop ancillary content (details, progress size info) before touching the taskID.
429 if !truncateDetails(lines, overflow) && !truncateProgressSize(lines) && !truncateLongestTaskID(lines, overflow, minIDLen) {
430 break // Can't truncate further
431 }
432 }
433}
434
435// maxStatusLength returns the maximum status text length across all lines.
436func maxStatusLength(lines []lineData) int {

Calls 6

maxStatusLengthFunction · 0.85
maxBeforeStatusWidthFunction · 0.85
computeOverflowFunction · 0.85
truncateDetailsFunction · 0.85
truncateProgressSizeFunction · 0.85
truncateLongestTaskIDFunction · 0.85