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)
- 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
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)
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
}
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 WithTotalWidth ¶
func WithTotalWidth(width int) SideBySideOption
WithTotalWidth sets the total width for side-by-side view