Documentation
¶
Index ¶
- Constants
- Variables
- func AccentColor() (string, bool)
- func AccentDivider(label string, width int) string
- func Badge(text string) string
- func Bullet(msg string) string
- func Check(msg string) string
- func Checkf(format string, args ...interface{}) string
- func ConfigureMarkdownCodeTheme(theme string)
- func ConfigureTheme(accent string)
- func Count(n int, singular, plural string) string
- func Divider(label string, width int) string
- func DividerWithAccentLabel(label string, width int) string
- func Error(msg string) string
- func ErrorWarningCounts(errors, warnings int) string
- func Errorf(format string, args ...interface{}) string
- func FieldAdd(field, value string) string
- func FieldChange(field, oldValue, newValue string) string
- func FieldRemove(field, value string) string
- func FieldSet(field, value string) string
- func FilePath(path string) string
- func FormatRowNum(num, maxNum int) string
- func Header(msg string) string
- func HighlightTraits(text string) string
- func Hint(msg string) string
- func Indent(n int, text string) string
- func Info(msg string) string
- func Infof(format string, args ...interface{}) string
- func LineNum(n int) string
- func LineNumPadded(n int, width int) string
- func Metadata(pairs ...string) string
- func MetadataItem(key, value string) string
- func PadRight(s string, width int) string
- func RenderMarkdown(content string, width int) (string, error)
- func ResultCount(n int) string
- func SectionHeader(msg string) string
- func Star(msg string) string
- func Starf(format string, args ...interface{}) string
- func Trait(traitType string, value string) string
- func TruncateWithEllipsis(s string, maxLen int) string
- func VisibleLen(s string) int
- func Warning(msg string) string
- func Warningf(format string, args ...interface{}) string
- func WrapTextTwoLines(text string, maxLen int) (line1, line2 string)
- type Alignment
- type ColumnDef
- type DisplayContext
- type List
- type Progress
- type ResultRow
- type ResultsTable
- type Spinner
- type Table
Constants ¶
const ( SymbolCheck = "✓" // Explicit action success (created, added, etc.) SymbolStar = "✦" // Concluding/summary messages (no issues, results) SymbolError = "✗" SymbolWarning = "!" SymbolInfo = "*" SymbolDot = "•" SymbolDash = "—" SymbolAttention = "»" )
Symbols for status indicators
const DefaultTermWidth = 120
DefaultTermWidth is the fallback terminal width when detection fails.
const MarkdownRenderMargin = 2
MarkdownRenderMargin is the left margin used for terminal markdown rendering.
Variables ¶
var ( // ColNum is the row number column (fixed width, right-aligned, muted). ColNum = ColumnDef{ Name: "num", MinWidth: 4, MaxWidth: 6, Align: AlignRight, Style: Muted, } // ColContent is the main content column (flexible width). ColContent = ColumnDef{ Name: "content", WidthRatio: 0.55, MinWidth: 30, MaxWidth: 100, Align: AlignLeft, } // ColMeta is the metadata column (trait info, title, etc). ColMeta = ColumnDef{ Name: "meta", WidthRatio: 0.25, MinWidth: 15, MaxWidth: 35, Align: AlignLeft, Style: Muted, } // ColFile is the file location column. ColFile = ColumnDef{ Name: "file", WidthRatio: 0.20, MinWidth: 10, MaxWidth: 30, Align: AlignLeft, Style: Muted, } // ColBacklinksMeta is a wider metadata/content column used for backlinks/outlinks. ColBacklinksMeta = ColumnDef{ Name: "meta", WidthRatio: 0.70, MinWidth: 30, MaxWidth: 120, Align: AlignLeft, Style: Muted, } // ColBacklinksFile is a wider file column used for backlinks/outlinks. ColBacklinksFile = ColumnDef{ Name: "file", WidthRatio: 0.30, MinWidth: 18, MaxWidth: 60, Align: AlignLeft, Style: Muted, } )
Standard column definitions shared across retrieval types.
var ( // SearchLayout is used for search results: [num, content, meta, file] SearchLayout = []ColumnDef{ColNum, ColContent, ColMeta, ColFile} // TraitLayout is used for trait query results: [num, content, meta, file] TraitLayout = []ColumnDef{ColNum, ColContent, ColMeta, ColFile} // BacklinksLayout is used for backlinks: [num, meta, file] BacklinksLayout = []ColumnDef{ColNum, ColBacklinksMeta, ColBacklinksFile} )
Standard layouts for each retrieval type.
var ( // Muted style for secondary info, hints, line numbers Muted = lipgloss.NewStyle().Foreground(lipgloss.Color("8")) // Bright Black (gray) // Bold style for emphasis and highlights Bold = lipgloss.NewStyle().Bold(true) // Accent style for optional user-configurable highlights. // Defaults to Bold with no color when accent is not configured. Accent = Bold // Syntax style for code-like tokens and Raven syntax markers. // Defaults to cyan for visibility when no accent is configured. Syntax = lipgloss.NewStyle().Foreground(lipgloss.Color("6")).Bold(true) // SyntaxSubtle style for supporting syntax values. SyntaxSubtle = lipgloss.NewStyle().Foreground(lipgloss.Color("6")) )
Functions ¶
func AccentColor ¶
AccentColor returns the currently configured accent color, if any.
func AccentDivider ¶
AccentDivider returns a section divider rendered with the accent style.
func ConfigureMarkdownCodeTheme ¶
func ConfigureMarkdownCodeTheme(theme string)
ConfigureMarkdownCodeTheme sets the code block theme used by Glamour. Invalid or empty values fall back to the default theme.
func ConfigureTheme ¶
func ConfigureTheme(accent string)
ConfigureTheme configures optional UI theme colors from config. Supported accent values:
- ANSI codes: "0" to "255"
- Hex colors: "#RRGGBB" or "#RGB"
Special values "none", "off", and "default" disable the accent color.
func DividerWithAccentLabel ¶
DividerWithAccentLabel renders a divider with muted dashes and an accent label.
func ErrorWarningCounts ¶
ErrorWarningCounts returns a formatted count string like "(3 errors, 2 warnings)"
func FieldChange ¶
FieldChange formats a field change as "field: old → new"
func FieldRemove ¶
FieldRemove formats a removed field as "- field: value"
func FormatRowNum ¶
FormatRowNum formats a row number with consistent width.
func HighlightTraits ¶
HighlightTraits highlights all @trait patterns in text. Traits are bold, values are muted. Uses parser.TraitHighlightPattern as the canonical pattern for trait matching.
func LineNumPadded ¶
LineNumPadded returns a muted, right-padded line number
func MetadataItem ¶
MetadataItem returns a single "key: value" metadata item
func RenderMarkdown ¶
RenderMarkdown renders markdown content for terminal display using the shared Raven style configuration.
func ResultCount ¶
ResultCount returns a muted result count like "2 results"
func SectionHeader ¶
SectionHeader returns a styled section header with a leading symbol.
func Trait ¶
Trait formats a trait with styling. The @ and trait name use syntax styling, and the value (if any) uses a subtle syntax style.
func TruncateWithEllipsis ¶
TruncateWithEllipsis truncates a string to maxLen, adding ellipsis if needed. It tries to break at word boundaries.
func VisibleLen ¶
VisibleLen returns the visible length of a string, excluding ANSI escape codes
func WrapTextTwoLines ¶
WrapTextTwoLines wraps text into at most two lines, with the second line truncated.
Types ¶
type ColumnDef ¶
type ColumnDef struct {
Name string // Header name (used for debugging, not displayed in minimal style)
WidthRatio float64 // Proportion of available width (0.0-1.0), 0 means fixed width
MinWidth int // Minimum width in characters
MaxWidth int // Maximum width (0 = no limit)
Align Alignment // Text alignment
Style lipgloss.Style // Style to apply to cells in this column
}
ColumnDef defines a column in a ResultsTable.
type DisplayContext ¶
type DisplayContext struct {
TermWidth int // detected or fallback terminal width
IsTTY bool // whether stdout is a terminal
}
DisplayContext holds display parameters, auto-detecting terminal width. It is the single source of truth for display settings.
func NewDisplayContext ¶
func NewDisplayContext() *DisplayContext
NewDisplayContext creates a DisplayContext, auto-detecting terminal dimensions.
func NewDisplayContextWithWidth ¶
func NewDisplayContextWithWidth(width int) *DisplayContext
NewDisplayContextWithWidth creates a DisplayContext with a fixed width (for testing).
func (*DisplayContext) AvailableWidth ¶
func (d *DisplayContext) AvailableWidth(leftMargin int) int
AvailableWidth returns the usable width after accounting for left margin.
type List ¶
type List struct {
// contains filtered or unexported fields
}
List provides a simple indented list renderer
type Progress ¶
type Progress struct {
// contains filtered or unexported fields
}
Progress displays a simple progress indicator for counted operations.
func NewProgress ¶
NewProgress creates a new progress indicator.
func (*Progress) DoneWithMessage ¶
DoneWithMessage finishes the progress and prints a message.
type ResultRow ¶
type ResultRow struct {
Num int // Row number (1-indexed)
Cells []string // Cell values for each column
Location string // Location for hyperlinks (file:line format)
}
ResultRow represents a single row in the results table.
type ResultsTable ¶
type ResultsTable struct {
// contains filtered or unexported fields
}
ResultsTable provides a unified table renderer for all retrieval types.
func NewResultsTable ¶
func NewResultsTable(display *DisplayContext, columns []ColumnDef) *ResultsTable
NewResultsTable creates a new ResultsTable with the given display context and column layout.
func (*ResultsTable) AddRow ¶
func (t *ResultsTable) AddRow(row ResultRow)
AddRow adds a row to the table.
func (*ResultsTable) ContentWidth ¶
func (t *ResultsTable) ContentWidth(columnName string) int
ContentWidth returns the calculated width for a specific column by name. This allows callers to prepare content (e.g., snippet extraction) based on actual available width.
func (*ResultsTable) GetColumnWidth ¶
func (t *ResultsTable) GetColumnWidth(index int) int
GetColumnWidth returns the calculated width for a column by index.
func (*ResultsTable) Render ¶
func (t *ResultsTable) Render() string
Render generates the table output as a string.
type Spinner ¶
type Spinner struct {
// contains filtered or unexported fields
}
Spinner displays an animated spinner with a message.
func NewSpinner ¶
NewSpinner creates a new spinner with the given message.
func (*Spinner) Stop ¶
func (s *Spinner) Stop()
Stop stops the spinner and optionally shows a final message.
func (*Spinner) StopWithCheck ¶
StopWithCheck stops the spinner and prints a success message.
func (*Spinner) StopWithMessage ¶
StopWithMessage stops the spinner and prints a final message.