buildRefCell assembles the flexible REF/TITLE cell within a visible budget. Only the title is truncated — the pin marker, ref, and "(archived)" suffix are always shown in full — so a narrow terminal degrades to ref + as much title as fits (possibly none) rather than ever hiding or slicing the ref. T
(pin, ref, title string, archived bool, budget int)
| 339 | // Truncation happens on the raw title before colorizing, so an ANSI escape is |
| 340 | // never cut mid-sequence. |
| 341 | func buildRefCell(pin, ref, title string, archived bool, budget int) string { |
| 342 | // Visible width consumed by everything except the title text. |
| 343 | fixed := displayWidth(pin) |
| 344 | refPrefix := "" |
| 345 | if ref != "" { |
| 346 | refPrefix = BoldCyan.Sprint(ref) + " " |
| 347 | fixed += displayWidth(ref) + 2 |
| 348 | } |
| 349 | archivedSuffix := "" |
| 350 | if archived { |
| 351 | archivedSuffix = " " + Dim.Sprint("(archived)") |
| 352 | fixed += 2 + len("(archived)") |
| 353 | } |
| 354 | |
| 355 | shown := truncateTitle(title, budget-fixed) |
| 356 | |
| 357 | cell := pin + refPrefix |
| 358 | if shown != "" { |
| 359 | cell += Bold.Sprint(shown) |
| 360 | } |
| 361 | return cell + archivedSuffix |
| 362 | } |
| 363 | |
| 364 | // PrintItemTitles prints just item titles. |
| 365 | func PrintItemTitles(items []models.Item) { |
no test coverage detected