Documentation
¶
Overview ¶
Package display formats sessions for list-mode output using lipgloss and ANSI 16-color palette.
Index ¶
- Constants
- Variables
- func AdaptiveDirWidth(sessions []source.Session, termWidth int) int
- func AdaptiveIDWidth(sessions []source.Session) int
- func AdaptiveMsgWidth(sessions []source.Session) int
- func AdaptiveTitleWidth(titles []string) int
- func FormatDirCell(dir string, colWidth int, dim bool) string
- func FormatListRow(s source.Session, w ListWidths, dimDir bool) string
- func Header(w ListWidths) string
- func Sanitize(s string) string
- func TermWidth(w io.Writer) int
- func TruncateWidth(s string, maxCols int, tail string) string
- type ListWidths
Constants ¶
const (
MaxTitleLimit = 40 // baseline cap for adaptive title width
)
Column widths (display columns, not bytes).
Variables ¶
var ( ColorTime = lipgloss.Color("2") // green ColorTitle = lipgloss.Color("3") // yellow ColorID = lipgloss.Color("7") // white ColorMsg = lipgloss.Color("5") // magenta ColorSrc = lipgloss.Color("5") // magenta (same as msg) ColorDir = lipgloss.Color("6") // cyan ColorMuted = lipgloss.Color("8") // dark grey (separators, borders, dim text) ColorHeader = lipgloss.Color("7") // white (header row) ColorSpinner = lipgloss.Color("9") // bright red (renders as orange in most terminals, matches Claude brand) )
Shared ANSI 16-color palette used by both list mode and the interactive picker. Using ANSI 16 respects the user's terminal color theme.
Functions ¶
func AdaptiveDirWidth ¶
AdaptiveDirWidth returns the column width needed to display the widest CWDDisplay. When termWidth > 0, the result is capped at termWidth. When termWidth == 0, result is the natural maximum (no cap).
func AdaptiveIDWidth ¶
AdaptiveIDWidth returns the column width needed to display the widest session ID.
func AdaptiveMsgWidth ¶
AdaptiveMsgWidth returns the column width needed to display the widest message count. The minimum is len("MSG") so the header always fits.
func AdaptiveTitleWidth ¶
AdaptiveTitleWidth returns min(MaxTitleLimit, maxActualDisplayWidth) across titles.
func FormatDirCell ¶ added in v0.2.8
FormatDirCell renders a directory path with the basename in bold. The total rendered width is padded to colWidth display columns (0 = unconstrained). prefix and basename are rendered separately so only basename is bold. dim=true renders the cell faint (same path as previous row).
func FormatListRow ¶
func FormatListRow(s source.Session, w ListWidths, dimDir bool) string
FormatListRow formats a session for plain list output. dimDir=true renders the directory cell faint (same path as previous row).
func TermWidth ¶
TermWidth returns the terminal width of w, or 0 if w is not a TTY. Callers treat 0 as "unconstrained" (pipe / redirect).
func TruncateWidth ¶
TruncateWidth truncates s to at most maxCols display columns, CJK-aware. tail (e.g. "…") is appended when truncation occurs and counts toward maxCols. Uses lipgloss.Width (which wraps go-runewidth) to measure each candidate.
Types ¶
type ListWidths ¶
type ListWidths struct {
Title int
ID int
Msg int
Dir int // 0 means unconstrained (pipe mode — Dir rendered without Width padding)
Source int // 0 when not combined
}
ListWidths holds pre-computed column widths for list-mode rendering.
func ComputeListWidths ¶
func ComputeListWidths(sessions []source.Session, includeSource bool, termWidth int) ListWidths
ComputeListWidths computes adaptive column widths for all sessions. termWidth==0 means stdout is not a TTY; no bonus space is allocated.