Documentation
¶
Index ¶
- func ApplyCommit(commit Commit, writeFn func(string, string) error, removeFn func(string) error) error
- func FormatDiff(diffText string, opts ...SideBySideOption) (string, error)
- func GenerateDiff(beforeContent, afterContent, fileName string) (string, int, int)
- func HighlightIntralineChanges(h *Hunk, style StyleConfig)
- func IdentifyFilesAdded(text string) []string
- func IdentifyFilesNeeded(text string) []string
- func LoadFiles(paths []string, openFn func(string) (string, error)) (map[string]string, error)
- func OpenFile(p string) (string, error)
- func ProcessPatch(text string, openFn func(string) (string, error), ...) (string, error)
- func RemoveFile(p string) error
- func RenderSideBySideHunk(fileName string, h Hunk, opts ...SideBySideOption) string
- func SyntaxHighlight(w io.Writer, source, fileName, formatter string, bg lipgloss.TerminalColor) error
- func ValidatePatch(patchText string, files map[string]string) (bool, string, error)
- func WriteFile(p string, content string) error
- type ActionType
- type Chunk
- type Commit
- type DiffError
- type DiffLine
- type DiffResult
- type FileChange
- type Hunk
- type LineType
- type ParseConfig
- type ParseOption
- type Parser
- type Patch
- type PatchAction
- type Segment
- type SideBySideConfig
- type SideBySideOption
- type StyleConfig
- type StyleOption
- func WithAddedFg(color lipgloss.Color) StyleOption
- func WithAddedHighlightColors(bg, fg lipgloss.Color) StyleOption
- func WithAddedLineBg(color lipgloss.Color) StyleOption
- func WithAddedLineNumberBg(color lipgloss.Color) StyleOption
- func WithContextLineBg(color lipgloss.Color) StyleOption
- func WithFileNameFg(color lipgloss.Color) StyleOption
- func WithHighlightStyle(style string) StyleOption
- func WithHunkLineBg(color lipgloss.Color) StyleOption
- func WithHunkLineFg(color lipgloss.Color) StyleOption
- func WithLineNumberFg(color lipgloss.Color) StyleOption
- func WithRemovedFg(color lipgloss.Color) StyleOption
- func WithRemovedHighlightColors(bg, fg lipgloss.Color) StyleOption
- func WithRemovedLineBg(color lipgloss.Color) StyleOption
- func WithRemovedLineNumberBg(color lipgloss.Color) StyleOption
- func WithShowHeader(show bool) StyleOption
- func WithShowHunkHeader(show bool) StyleOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyCommit ¶
func FormatDiff ¶
func FormatDiff(diffText string, opts ...SideBySideOption) (string, error)
FormatDiff creates a side-by-side formatted view of a diff
func GenerateDiff ¶
GenerateDiff creates a unified diff from two file contents
func HighlightIntralineChanges ¶
func HighlightIntralineChanges(h *Hunk, style StyleConfig)
HighlightIntralineChanges updates lines in a hunk to show character-level differences
func IdentifyFilesAdded ¶
func IdentifyFilesNeeded ¶
func ProcessPatch ¶
func RemoveFile ¶
func RenderSideBySideHunk ¶
func RenderSideBySideHunk(fileName string, h Hunk, opts ...SideBySideOption) string
RenderSideBySideHunk formats a hunk for side-by-side display
func SyntaxHighlight ¶
func SyntaxHighlight(w io.Writer, source, fileName, formatter string, bg lipgloss.TerminalColor) error
SyntaxHighlight applies syntax highlighting to text based on file extension
func ValidatePatch ¶
Types ¶
type ActionType ¶
type ActionType string
const ( ActionAdd ActionType = "add" ActionDelete ActionType = "delete" ActionUpdate ActionType = "update" )
type DiffLine ¶
type DiffLine struct { OldLineNo int // Line number in old file (0 for added lines) NewLineNo int // Line number in new file (0 for removed lines) Kind LineType // Type of line (added, removed, context) Content string // Content of the line Segments []Segment // Segments for intraline highlighting }
DiffLine represents a single line in a diff
type DiffResult ¶
DiffResult contains the parsed result of a diff
func ParseUnifiedDiff ¶
func ParseUnifiedDiff(diff string) (DiffResult, error)
ParseUnifiedDiff parses a unified diff format string into structured data
type FileChange ¶
type FileChange struct { Type ActionType OldContent *string NewContent *string MovePath *string }
type ParseConfig ¶
type ParseConfig struct {
ContextSize int // Number of context lines to include
}
ParseConfig configures the behavior of diff parsing
type ParseOption ¶
type ParseOption func(*ParseConfig)
ParseOption modifies a ParseConfig
func WithContextSize ¶
func WithContextSize(size int) ParseOption
WithContextSize sets the number of context lines to include
type Patch ¶
type Patch struct {
Actions map[string]PatchAction
}
type PatchAction ¶
type PatchAction struct { Type ActionType NewFile *string Chunks []Chunk MovePath *string }
type SideBySideConfig ¶
type SideBySideConfig struct { TotalWidth int Style StyleConfig }
SideBySideConfig configures the rendering of side-by-side diffs
func NewSideBySideConfig ¶
func NewSideBySideConfig(opts ...SideBySideOption) SideBySideConfig
NewSideBySideConfig creates a SideBySideConfig with default values
type SideBySideOption ¶
type SideBySideOption func(*SideBySideConfig)
SideBySideOption modifies a SideBySideConfig
func WithStyle ¶
func WithStyle(style StyleConfig) SideBySideOption
WithStyle sets the styling configuration
func WithStyleOptions ¶
func WithStyleOptions(opts ...StyleOption) SideBySideOption
WithStyleOptions applies the specified style options
func WithTotalWidth ¶
func WithTotalWidth(width int) SideBySideOption
WithTotalWidth sets the total width for side-by-side view
type StyleConfig ¶
type StyleConfig struct { ShowHeader bool ShowHunkHeader bool FileNameFg lipgloss.Color // Background colors RemovedLineBg lipgloss.Color AddedLineBg lipgloss.Color ContextLineBg lipgloss.Color HunkLineBg lipgloss.Color RemovedLineNumberBg lipgloss.Color AddedLineNamerBg lipgloss.Color // Foreground colors HunkLineFg lipgloss.Color RemovedFg lipgloss.Color AddedFg lipgloss.Color LineNumberFg lipgloss.Color RemovedHighlightFg lipgloss.Color AddedHighlightFg lipgloss.Color // Highlight settings HighlightStyle string RemovedHighlightBg lipgloss.Color AddedHighlightBg lipgloss.Color }
StyleConfig defines styling for diff rendering
func NewStyleConfig ¶
func NewStyleConfig(opts ...StyleOption) StyleConfig
NewStyleConfig creates a StyleConfig with default values
type StyleOption ¶
type StyleOption func(*StyleConfig)
StyleOption is a function that modifies a StyleConfig
func WithAddedFg ¶
func WithAddedFg(color lipgloss.Color) StyleOption
func WithAddedHighlightColors ¶
func WithAddedHighlightColors(bg, fg lipgloss.Color) StyleOption
func WithAddedLineBg ¶
func WithAddedLineBg(color lipgloss.Color) StyleOption
func WithAddedLineNumberBg ¶
func WithAddedLineNumberBg(color lipgloss.Color) StyleOption
func WithContextLineBg ¶
func WithContextLineBg(color lipgloss.Color) StyleOption
func WithHighlightStyle ¶
func WithHighlightStyle(style string) StyleOption
func WithHunkLineBg ¶
func WithHunkLineBg(color lipgloss.Color) StyleOption
func WithHunkLineFg ¶
func WithHunkLineFg(color lipgloss.Color) StyleOption
func WithLineNumberFg ¶
func WithLineNumberFg(color lipgloss.Color) StyleOption
func WithRemovedFg ¶
func WithRemovedFg(color lipgloss.Color) StyleOption
func WithRemovedHighlightColors ¶
func WithRemovedHighlightColors(bg, fg lipgloss.Color) StyleOption
func WithRemovedLineBg ¶
func WithRemovedLineBg(color lipgloss.Color) StyleOption
func WithRemovedLineNumberBg ¶
func WithRemovedLineNumberBg(color lipgloss.Color) StyleOption
func WithShowHeader ¶
func WithShowHeader(show bool) StyleOption
func WithShowHunkHeader ¶
func WithShowHunkHeader(show bool) StyleOption