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

Function buildRefCell

internal/cli/format.go:341–362  ·  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

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

Callers 1

renderItemTableFunction · 0.85

Calls 2

displayWidthFunction · 0.85
truncateTitleFunction · 0.85

Tested by

no test coverage detected