MCPcopy Create free account
hub / github.com/PerpetualSoftware/pad / buildRefCell

Function buildRefCell

internal/cli/format.go:385–406  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

383// Truncation happens on the raw title before colorizing, so an ANSI escape is
384// never cut mid-sequence.
385func 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.
409func PrintItemTitles(items []models.Item) {

Callers 1

renderItemTableFunction · 0.85

Calls 2

displayWidthFunction · 0.85
truncateTitleFunction · 0.85

Tested by

no test coverage detected