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)
| 383 | // Truncation happens on the raw title before colorizing, so an ANSI escape is |
| 384 | // never cut mid-sequence. |
| 385 | func buildRefCell(pin, ref, title string, archived bool, budget int) string { |
| 386 | // Visible width consumed by everything except the title text. |
| 387 | fixed := displayWidth(pin) |
| 388 | refPrefix := "" |
| 389 | if ref != "" { |
| 390 | refPrefix = BoldCyan.Sprint(ref) + " " |
| 391 | fixed += displayWidth(ref) + 2 |
| 392 | } |
| 393 | archivedSuffix := "" |
| 394 | if archived { |
| 395 | archivedSuffix = " " + Dim.Sprint("(archived)") |
| 396 | fixed += 2 + len("(archived)") |
| 397 | } |
| 398 | |
| 399 | shown := truncateTitle(title, budget-fixed) |
| 400 | |
| 401 | cell := pin + refPrefix |
| 402 | if shown != "" { |
| 403 | cell += Bold.Sprint(shown) |
| 404 | } |
| 405 | return cell + archivedSuffix |
| 406 | } |
| 407 | |
| 408 | // PrintItemTitles prints just item titles. |
| 409 | func PrintItemTitles(items []models.Item) { |
no test coverage detected