MCPcopy Index your code
hub / github.com/docker/cli / adjustColumns

Function adjustColumns

cli/command/image/tree.go:353–380  ·  view source on GitHub ↗

adjustColumns adjusts the width of the first column to maximize the space available for image names and removes any columns that would be too narrow to display their content.

(width uint, columns []imgColumn, images []topImage)

Source from the content-addressed store, hash-verified

351// available for image names and removes any columns that would be too narrow
352// to display their content.
353func adjustColumns(width uint, columns []imgColumn, images []topImage) []imgColumn {
354 nameWidth := int(width)
355 if nameWidth > 0 {
356 for idx, h := range columns {
357 if h.Width == 0 {
358 continue
359 }
360 d := h.Width
361 if idx > 0 {
362 d += columnSpacing
363 }
364 // If the first column gets too short, remove remaining columns
365 if nameWidth-d < 12 {
366 columns = columns[:idx]
367 break
368 }
369 nameWidth -= d
370 }
371 }
372
373 // Try to make the first column as narrow as possible
374 widest := widestFirstColumnValue(columns, images)
375 if width == 0 || nameWidth > widest {
376 nameWidth = widest
377 }
378 columns[0].Width = nameWidth
379 return columns
380}
381
382func generateLegend(out tui.Output, width uint) string {
383 var legend string

Callers 1

printImageTreeFunction · 0.85

Calls 1

widestFirstColumnValueFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…