diff

package
v0.326.0 Latest Latest
Warning

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

Go to latest
Published: May 27, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DiffLayout

type DiffLayout int
const (
	DiffLayoutUnified DiffLayout = iota
	DiffLayoutSplit
)

type DiffLine

type DiffLine struct {
	OldNum  int
	NewNum  int
	Content string
	Type    DiffLineType
}

DiffLine represents a single parsed line in a unified diff.

type DiffLineType

type DiffLineType int

DiffLineType identifies the type of a diff line.

const (
	DiffLineContext DiffLineType = iota
	DiffLineAdd
	DiffLineDelete
)

type DiffStyles

type DiffStyles struct {
	Header        lipgloss.Style
	HeaderPath    lipgloss.Style
	HeaderStats   lipgloss.Style
	HeaderMode    lipgloss.Style
	HunkHeader    lipgloss.Style
	Gap           lipgloss.Style
	AddedLine     lipgloss.Style
	RemovedLine   lipgloss.Style
	ContextLine   lipgloss.Style
	AddedNumber   lipgloss.Style
	RemovedNumber lipgloss.Style
	ContextNumber lipgloss.Style
	AddedMarker   lipgloss.Style
	RemovedMarker lipgloss.Style
	ContextMarker lipgloss.Style
	Separator     lipgloss.Style
	Placeholder   lipgloss.Style
}

DiffStyles contains the lipgloss styles used by DiffView.

func NewDiffStyles

func NewDiffStyles(theme tuitheme.Theme) DiffStyles

NewDiffStyles builds styles using the current TUI theme.

type DiffView

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

DiffView renders parsed unified diffs in unified or split mode.

func NewDiffView

func NewDiffView(opts DiffViewOptions) *DiffView

func (*DiffView) Init

func (d *DiffView) Init() tea.Cmd

func (*DiffView) SetContextLines

func (d *DiffView) SetContextLines(lines int)

func (*DiffView) SetDiff

func (d *DiffView) SetDiff(diff string)

func (*DiffView) SetLayout

func (d *DiffView) SetLayout(layout DiffLayout)

func (*DiffView) SetSize

func (d *DiffView) SetSize(width, height int)

func (*DiffView) Update

func (d *DiffView) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (*DiffView) View

func (d *DiffView) View() string

type DiffViewOptions

type DiffViewOptions struct {
	Diff         string
	Width        int
	Height       int
	Layout       DiffLayout
	ContextLines int
}

DiffViewOptions configures a new DiffView.

type FileDiff

type FileDiff struct {
	OldFile   string
	NewFile   string
	FilePath  string
	Hunks     []Hunk
	Additions int
	Deletions int
}

FileDiff contains a parsed unified diff for a single file.

func ParseUnifiedDiff

func ParseUnifiedDiff(diff string) *FileDiff

ParseUnifiedDiff parses a unified diff into a FileDiff structure.

type Hunk

type Hunk struct {
	Header             string
	OldStart, OldLines int
	NewStart, NewLines int
	Lines              []DiffLine
}

Hunk represents a unified diff hunk.

Jump to

Keyboard shortcuts

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