style

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Code generated by enum generator; DO NOT EDIT.

Code generated by enum generator; DO NOT EDIT.

Index

Constants

This section is empty.

Variables

View Source
var (
	// zero value sentinel
	ColorKeyUnknown      = ColorKey{/* contains filtered or unexported fields */}
	ColorKeyAccentFg     = ColorKey{/* contains filtered or unexported fields */}
	ColorKeyMutedFg      = ColorKey{/* contains filtered or unexported fields */}
	ColorKeyAnnotationFg = ColorKey{/* contains filtered or unexported fields */}
	// internal fallback: StatusFg || MutedFg
	ColorKeyStatusFg     = ColorKey{/* contains filtered or unexported fields */}
	ColorKeyTreePaneBg   = ColorKey{/* contains filtered or unexported fields */}
	ColorKeyDiffPaneBg   = ColorKey{/* contains filtered or unexported fields */}
	ColorKeyAddLineBg    = ColorKey{/* contains filtered or unexported fields */}
	ColorKeyRemoveLineBg = ColorKey{/* contains filtered or unexported fields */}
	ColorKeyModifyLineBg = ColorKey{/* contains filtered or unexported fields */}
	ColorKeyWordAddBg    = ColorKey{/* contains filtered or unexported fields */}
	ColorKeyWordRemoveBg = ColorKey{/* contains filtered or unexported fields */}
	ColorKeySearchBg     = ColorKey{/* contains filtered or unexported fields */}
	ColorKeyAddLineFg    = ColorKey{/* contains filtered or unexported fields */}
	ColorKeyRemoveLineFg = ColorKey{/* contains filtered or unexported fields */}
	ColorKeyNormalFg     = ColorKey{/* contains filtered or unexported fields */}
	ColorKeySelectedFg   = ColorKey{/* contains filtered or unexported fields */}
)

Public constants for colorKey values

View Source
var (
	StyleKeyUnknown = StyleKey{/* contains filtered or unexported fields */}
	// diff line styles
	StyleKeyLineAdd              = StyleKey{/* contains filtered or unexported fields */}
	StyleKeyLineRemove           = StyleKey{/* contains filtered or unexported fields */}
	StyleKeyLineContext          = StyleKey{/* contains filtered or unexported fields */}
	StyleKeyLineModify           = StyleKey{/* contains filtered or unexported fields */}
	StyleKeyLineAddHighlight     = StyleKey{/* contains filtered or unexported fields */}
	StyleKeyLineRemoveHighlight  = StyleKey{/* contains filtered or unexported fields */}
	StyleKeyLineContextHighlight = StyleKey{/* contains filtered or unexported fields */}
	StyleKeyLineModifyHighlight  = StyleKey{/* contains filtered or unexported fields */}
	StyleKeyLineNumber           = StyleKey{/* contains filtered or unexported fields */}
	// pane styles
	StyleKeyTreePane       = StyleKey{/* contains filtered or unexported fields */}
	StyleKeyTreePaneActive = StyleKey{/* contains filtered or unexported fields */}
	StyleKeyDiffPane       = StyleKey{/* contains filtered or unexported fields */}
	StyleKeyDiffPaneActive = StyleKey{/* contains filtered or unexported fields */}
	// file tree entry styles
	StyleKeyDirEntry       = StyleKey{/* contains filtered or unexported fields */}
	StyleKeyFileEntry      = StyleKey{/* contains filtered or unexported fields */}
	StyleKeyFileSelected   = StyleKey{/* contains filtered or unexported fields */}
	StyleKeyAnnotationMark = StyleKey{/* contains filtered or unexported fields */}
	StyleKeyReviewedMark   = StyleKey{/* contains filtered or unexported fields */}
	// file status styles
	StyleKeyStatusAdded     = StyleKey{/* contains filtered or unexported fields */}
	StyleKeyStatusDeleted   = StyleKey{/* contains filtered or unexported fields */}
	StyleKeyStatusUntracked = StyleKey{/* contains filtered or unexported fields */}
	StyleKeyStatusDefault   = StyleKey{/* contains filtered or unexported fields */}
	// chrome styles
	StyleKeyStatusBar   = StyleKey{/* contains filtered or unexported fields */}
	StyleKeySearchMatch = StyleKey{/* contains filtered or unexported fields */}
	// ti.TextStyle / ti.PromptStyle in newAnnotationInput
	StyleKeyAnnotInputText = StyleKey{/* contains filtered or unexported fields */}
	// ti.PlaceholderStyle
	StyleKeyAnnotInputPlaceholder = StyleKey{/* contains filtered or unexported fields */}
	// ti.Cursor.Style / ti.Cursor.TextStyle
	StyleKeyAnnotInputCursor = StyleKey{/* contains filtered or unexported fields */}
	// annotation list popup border
	StyleKeyAnnotListBorder = StyleKey{/* contains filtered or unexported fields */}
	// help overlay box
	StyleKeyHelpBox = StyleKey{/* contains filtered or unexported fields */}
	// theme selector box
	StyleKeyThemeSelectBox = StyleKey{/* contains filtered or unexported fields */}
	// theme selector focused state
	StyleKeyThemeSelectBoxFocused = StyleKey{/* contains filtered or unexported fields */}
)

Public constants for styleKey values

View Source
var ColorKeyNames = []string{
	"Unknown",
	"AccentFg",
	"MutedFg",
	"AnnotationFg",
	"StatusFg",
	"TreePaneBg",
	"DiffPaneBg",
	"AddLineBg",
	"RemoveLineBg",
	"ModifyLineBg",
	"WordAddBg",
	"WordRemoveBg",
	"SearchBg",
	"AddLineFg",
	"RemoveLineFg",
	"NormalFg",
	"SelectedFg",
}

ColorKeyNames contains all possible enum names

ColorKeyValues contains all possible enum values

View Source
var StyleKeyNames = []string{
	"Unknown",
	"LineAdd",
	"LineRemove",
	"LineContext",
	"LineModify",
	"LineAddHighlight",
	"LineRemoveHighlight",
	"LineContextHighlight",
	"LineModifyHighlight",
	"LineNumber",
	"TreePane",
	"TreePaneActive",
	"DiffPane",
	"DiffPaneActive",
	"DirEntry",
	"FileEntry",
	"FileSelected",
	"AnnotationMark",
	"ReviewedMark",
	"StatusAdded",
	"StatusDeleted",
	"StatusUntracked",
	"StatusDefault",
	"StatusBar",
	"SearchMatch",
	"AnnotInputText",
	"AnnotInputPlaceholder",
	"AnnotInputCursor",
	"AnnotListBorder",
	"HelpBox",
	"ThemeSelectBox",
	"ThemeSelectBoxFocused",
}

StyleKeyNames contains all possible enum names

StyleKeyValues contains all possible enum values

Functions

func AnsiFg

func AnsiFg(hex string) string

AnsiFg returns an ANSI 24-bit foreground color escape for a #RRGGBB hex string. returns empty string for invalid input.

func ColorKeyIter

func ColorKeyIter() func(yield func(ColorKey) bool)

ColorKeyIter returns a function compatible with Go 1.23's range-over-func syntax. It yields all ColorKey values in declaration order. Example:

for v := range ColorKeyIter() {
    // use v
}

func StyleKeyIter

func StyleKeyIter() func(yield func(StyleKey) bool)

StyleKeyIter returns a function compatible with Go 1.23's range-over-func syntax. It yields all StyleKey values in declaration order. Example:

for v := range StyleKeyIter() {
    // use v
}

func Write

func Write(w io.Writer, c Color) (int, error)

Write writes a Color value to w. returns the number of bytes written and any error. if c is empty, writes nothing and returns (0, nil).

Types

type Color

type Color string

Color is an ANSI escape sequence ready to write to a terminal stream. Zero value is an empty Color (no-op when written).

Color has no methods. fmt verbs work on the underlying string value (since Color is a string type alias), and emptiness is checked with c != "". The style.Write(w, c) helper handles io.Writer cases that need a string() cast. If a specific call site later requires methods on Color, add them then — not speculatively.

const (
	ResetFg Color = "\033[39m"
	ResetBg Color = "\033[49m"
)

theme-independent reset sequences.

type ColorKey

type ColorKey struct {
	// contains filtered or unexported fields
}

ColorKey is the exported type for the enum

func MustColorKey

func MustColorKey(v string) ColorKey

MustColorKey is like ParseColorKey but panics if string is invalid

func ParseColorKey

func ParseColorKey(v string) (ColorKey, error)

ParseColorKey converts string to colorKey enum value. Parsing is always case-insensitive.

func (ColorKey) Index

func (e ColorKey) Index() int

Index returns the underlying integer value

func (ColorKey) MarshalText

func (e ColorKey) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler

func (ColorKey) String

func (e ColorKey) String() string

func (*ColorKey) UnmarshalText

func (e *ColorKey) UnmarshalText(text []byte) error

UnmarshalText implements encoding.TextUnmarshaler

type Colors

type Colors struct {
	Accent       string // active pane borders, dir names
	Border       string // inactive pane borders
	Normal       string // file entries, context lines
	Muted        string // divider lines, status bar
	SelectedFg   string // selected file text
	SelectedBg   string // selected file background
	Annotation   string // annotation text and markers
	CursorFg     string // diff cursor indicator foreground
	CursorBg     string // diff cursor line background
	AddFg        string // added line foreground
	AddBg        string // added line background
	RemoveFg     string // removed line foreground
	RemoveBg     string // removed line background
	WordAddBg    string // intra-line word-diff add background (auto-derived if empty)
	WordRemoveBg string // intra-line word-diff remove background (auto-derived if empty)
	ModifyFg     string // modified line foreground (collapsed mode)
	ModifyBg     string // modified line background (collapsed mode)
	TreeBg       string // file tree pane background
	DiffBg       string // diff pane background
	StatusFg     string // status bar foreground
	StatusBg     string // status bar background
	SearchFg     string // search match foreground
	SearchBg     string // search match background
}

Colors holds hex color values (#rrggbb) for TUI rendering. This is the construction input for NewResolver — it is not part of any type's runtime API.

type Renderer

type Renderer struct {
	// contains filtered or unexported fields
}

Renderer produces complete rendered strings for specific UI widgets (annotation marks, cursor cells, status separators, file status marks). It composes multiple Color lookups into final ANSI-tagged strings.

func NewRenderer

func NewRenderer(res Resolver) Renderer

NewRenderer wires a Renderer to a Resolver. The caller is responsible for constructing the Resolver first (via NewResolver or PlainResolver).

func (Renderer) AnnotationInline

func (r Renderer) AnnotationInline(text string) string

AnnotationInline renders an inline annotation with italic styling using raw ANSI sequences. uses AnnotationFg and DiffPaneBg from the resolver.

func (Renderer) DiffCursor

func (r Renderer) DiffCursor(noColors bool) string

DiffCursor renders the cursor glyph using raw ANSI sequences instead of lipgloss.Render() to avoid \033[0m full reset that kills the outer DiffBg background. when noColors is true, falls back to reverse video.

func (Renderer) FileAnnotationMark

func (r Renderer) FileAnnotationMark() string

FileAnnotationMark returns a colored annotation marker for files with annotations. uses AnnotationFg with ResetFg after the marker.

func (Renderer) FileReviewedMark

func (r Renderer) FileReviewedMark() string

FileReviewedMark returns a colored checkmark for reviewed files. uses AddFg for the checkmark and Normal for the reset; falls back to ResetFg when Colors.Normal is empty to prevent the AddFg color from bleeding into subsequent text on the same line.

func (Renderer) FileStatusMark

func (r Renderer) FileStatusMark(status diff.FileStatus) string

FileStatusMark returns a colored file status character (A, M, D, ?, etc.) followed by a space, using raw ANSI sequences to avoid lipgloss full reset. restores the Normal foreground after the status character; falls back to ResetFg when Colors.Normal is empty to prevent the status color from bleeding into subsequent text on the same line.

func (Renderer) StatusBarSeparator

func (r Renderer) StatusBarSeparator() string

StatusBarSeparator returns a separator string for the status bar, styled with muted foreground for the pipe and status foreground for the surrounding spaces.

type Resolver

type Resolver struct {
	// contains filtered or unexported fields
}

Resolver holds pre-materialized color and lipgloss style tables and dispatches lookups by key or by diff.ChangeType. All fields are private — callers access values through methods only.

func NewResolver

func NewResolver(c Colors) Resolver

NewResolver builds a Resolver from a Colors palette. Normalizes the input, builds all lipgloss.Style values, stores them privately.

func PlainResolver

func PlainResolver() Resolver

PlainResolver returns a Resolver with no-color styling — used for --no-colors mode. Borders are preserved; all color styling is stripped.

func (Resolver) Color

func (r Resolver) Color(k ColorKey) Color

Color returns the ANSI escape sequence for the given color key. ColorKeyStatusFg falls back to MutedFg when Colors.StatusFg is empty. returns empty Color for ColorKeyUnknown.

func (Resolver) IndicatorBg

func (r Resolver) IndicatorBg(change diff.ChangeType) Color

IndicatorBg returns the background color for a horizontal scroll indicator, falling back to the diff pane background when the line has no explicit bg.

func (Resolver) LineBg

func (r Resolver) LineBg(change diff.ChangeType) Color

LineBg returns the ANSI background escape sequence for a diff change type. ChangeAdd → AddBg, ChangeRemove → RemoveBg, everything else → empty.

func (Resolver) LineStyle

func (r Resolver) LineStyle(change diff.ChangeType, highlighted bool) lipgloss.Style

LineStyle returns the lipgloss.Style for a diff line based on change type and whether syntax highlighting is active.

func (Resolver) Style

func (r Resolver) Style(k StyleKey) lipgloss.Style

Style returns the pre-built lipgloss.Style for the given style key. returns an empty lipgloss.Style for unknown keys.

func (Resolver) WordDiffBg

func (r Resolver) WordDiffBg(change diff.ChangeType) Color

WordDiffBg returns the ANSI background escape for intra-line word-diff highlighting. ChangeAdd → WordAddBg, ChangeRemove → WordRemoveBg, everything else → empty.

type SGR

type SGR struct{}

SGR handles re-emission of ANSI SGR (Select Graphic Rendition) state across line boundaries. it is stateless and zero-value usable — the type exists to provide a method namespace for the consumer-side sgrProcessor interface contract.

func (SGR) Reemit

func (SGR) Reemit(lines []string) []string

Reemit scans each line for active SGR attributes (foreground color, background color, bold, italic, reverse video) and prepends the accumulated state to the next line. this fixes the issue where ansi.Wrap splits a line mid-token, causing continuation lines to lose their styling.

type StyleKey

type StyleKey struct {
	// contains filtered or unexported fields
}

StyleKey is the exported type for the enum

func MustStyleKey

func MustStyleKey(v string) StyleKey

MustStyleKey is like ParseStyleKey but panics if string is invalid

func ParseStyleKey

func ParseStyleKey(v string) (StyleKey, error)

ParseStyleKey converts string to styleKey enum value. Parsing is always case-insensitive.

func (StyleKey) Index

func (e StyleKey) Index() int

Index returns the underlying integer value

func (StyleKey) MarshalText

func (e StyleKey) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler

func (StyleKey) String

func (e StyleKey) String() string

func (*StyleKey) UnmarshalText

func (e *StyleKey) UnmarshalText(text []byte) error

UnmarshalText implements encoding.TextUnmarshaler

Jump to

Keyboard shortcuts

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