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)
| 351 | // available for image names and removes any columns that would be too narrow |
| 352 | // to display their content. |
| 353 | func 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 | |
| 382 | func generateLegend(out tui.Output, width uint) string { |
| 383 | var legend string |
no test coverage detected
searching dependent graphs…