Documentation
¶
Overview ¶
Package theme provides colored symbols and helpers for rendering VCS state.
Index ¶
Constants ¶
const DefaultColor = "15" // white
DefaultColor is the ANSI code used when a color name is not found.
Variables ¶
var ( // Dirty is the marker for a dirty working copy. Dirty = ColoredSymbol{Color: colorYellow, Symbol: "*"} // Conflict is the marker for unresolved conflicts. Conflict = ColoredSymbol{Color: colorRed, Symbol: "‼"} )
var ANSIColors = map[string]string{
"green": "2",
"blue": "4",
"yellow": "3",
"red": "1",
"magenta": "5",
"gray": "8",
"cyan": "14",
"purple": "62",
}
ANSIColors maps semantic color names to ANSI 256-color codes. Both CLI and TUI share these codes via lipgloss.
var StatusSymbolDocs = []SymbolDoc{
{Symbol: "✓", Description: "Synced with remote"},
{Symbol: "↑N", Description: "N commits ahead of remote"},
{Symbol: "↓N", Description: "N commits behind remote"},
{Symbol: "⇡N", Description: "Working copy ahead of bookmark (local)"},
{Symbol: "↑N↓N", Description: "Diverged (ahead and behind)"},
{Symbol: "∅", Description: "Local only, no remote"},
{Symbol: "‼", Description: "Unresolved conflict"},
{Symbol: "!", Description: "Bookmark conflict (jj)"},
{Symbol: "✗", Description: "Remote was deleted"},
{Symbol: "*", Description: "Dirty working copy"},
{Symbol: "?", Description: "Unknown remote state"},
}
StatusSymbolDocs returns documentation entries for all status symbols.
Functions ¶
func ColorCode ¶
ColorCode returns the ANSI 256-color code for the given semantic name. Returns DefaultColor for unknown names.
func FormatSymbols ¶
func FormatSymbols(status backend.RepoStatus, colorFn func(color, symbol string) string) string
FormatSymbols returns a string of colored symbols for the repo status, combining bookmark symbols with dirty and conflict markers. The colorFn parameter formats each symbol with its color, e.g.: lipgloss.NewStyle().Foreground(lipgloss.Color(theme.ColorCode(color))).Render(symbol).
func StateColor ¶
StateColor returns a color name for the given ref sync state.
Types ¶
type ColoredSymbol ¶
ColoredSymbol pairs a color name with a text symbol for display.
func BookmarkSymbols ¶
func BookmarkSymbols(bm backend.BookmarkStatus) []ColoredSymbol
BookmarkSymbols returns colored symbols representing the bookmark's sync state (synced, ahead, behind, diverged, gone, or no remote).