Documentation
¶
Overview ¶
Package diffview renders a unified diff as a color-coded, scrollable terminal block. Additions are green, removals are red, hunk headers are highlighted, context lines are muted. Optional line numbers from either side of the diff.
The component is render-only: a consumer parses (or generates) a list of Line values, hands them to WithLines, and the view does the rest. A ParseUnified helper is provided for the common `diff -u` case.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Line ¶
type Line struct {
Kind Kind
Old int // 1-based old line number, 0 if not applicable
New int // 1-based new line number, 0 if not applicable
Content string
}
Line is a single rendered row in the diff.
func ParseUnified ¶
ParseUnified converts a standard unified-diff string into a slice of Line values. Lines starting with "+++", "---", "diff", or "index" are classified as KindFile. Lines starting with "@@" are KindHunk. The usual leading-space / + / - convention drives KindContext, KindAdded, KindRemoved.
type View ¶
type View struct {
// contains filtered or unexported fields
}
View is a Bubble Tea model that renders a slice of Line values.
func (View) TotalLines ¶
TotalLines returns the number of rendered rows. Equals len(WithLines).
func (View) View ¶
View renders the visible window. Lines longer than the available content width are truncated with an ellipsis.
func (View) WithLineNumbers ¶
WithLineNumbers toggles the left-side line-number columns.
