Documentation
¶
Overview ¶
Package diff provides shared diff parsing and rendering utilities for the OpenCode TUI. This package contains common types and functions for rendering unified diffs.
Index ¶
- type DiffHunk
- type DiffLine
- type DiffLineType
- type Viewer
- func (dv *Viewer) Focused() bool
- func (dv *Viewer) Init() tea.Cmd
- func (dv *Viewer) Render(diffContent string) string
- func (dv *Viewer) RenderSimple(diffContent string) string
- func (dv *Viewer) SetDiffContent(content string) string
- func (dv *Viewer) SetFocused(focused bool)
- func (dv *Viewer) SetMaxWidth(maxWidth int)
- func (dv *Viewer) SetSize(width, height int)
- func (dv *Viewer) SetTheme(t theme.Theme)
- func (dv *Viewer) Update(msg tea.Msg) (tea.Model, tea.Cmd)
- func (dv *Viewer) View() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DiffHunk ¶
type DiffHunk struct {
OldStart int
OldCount int
NewStart int
NewCount int
Header string
Lines []DiffLine
}
DiffHunk represents a hunk (group of changes) in a diff.
func ParseUnifiedDiff ¶
ParseUnifiedDiff parses a unified diff string into structured DiffHunks.
type DiffLine ¶
type DiffLine struct {
Content string
LineType DiffLineType
OldLineNum int
NewLineNum int
}
DiffLine represents a single line in a diff with its metadata.
type DiffLineType ¶
type DiffLineType string
DiffLineType represents the type of line in a diff.
const ( DiffLineAdded DiffLineType = "+" DiffLineRemoved DiffLineType = "-" DiffLineContext DiffLineType = " " DiffLineHunk DiffLineType = "@@" )
type Viewer ¶
type Viewer struct {
// contains filtered or unexported fields
}
Viewer is a component for viewing file diffs with line-by-line coloring.
func NewViewerWithMaxWidth ¶
NewViewerWithMaxWidth creates a new diff viewer with the given maximum width.
func (*Viewer) RenderSimple ¶
RenderSimple renders a diff without borders, useful for inline display.
func (*Viewer) SetDiffContent ¶
SetDiffContent sets the diff content to display.
func (*Viewer) SetFocused ¶
SetFocused sets the focused state of the diff viewer.
func (*Viewer) SetMaxWidth ¶
SetMaxWidth sets the maximum width for the diff viewer.