theme

package
v0.12.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 12, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package theme provides colored symbols and helpers for rendering VCS state.

Index

Constants

View Source
const DefaultColor = "15" // white

DefaultColor is the ANSI code used when a color name is not found.

Variables

View Source
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: "‼"}
)
View Source
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.

View Source
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

func ColorCode(name string) string

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

func StateColor(state backend.RefState) string

StateColor returns a color name for the given ref sync state.

Types

type ColoredSymbol

type ColoredSymbol struct {
	Color  string
	Symbol string
}

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).

type SymbolDoc added in v0.4.0

type SymbolDoc struct {
	Symbol      string
	Description string
}

SymbolDoc documents a status symbol and its meaning.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL