diffview

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LineIndex

type LineIndex struct {
	TotalLines     int
	HunkOffsets    []int
	HunkLineCounts []int
}

func (*LineIndex) FindHunkForOffset

func (idx *LineIndex) FindHunkForOffset(offset int) (hunkIdx, lineInHunk int)

type MatchRange

type MatchRange struct {
	Start int
	End   int
}

type Model

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

func New

func New(cfg config.Config) Model

func (*Model) IsSideBySide

func (m *Model) IsSideBySide() bool

func (*Model) Scroll

func (m *Model) Scroll(delta int)

func (*Model) ScrollFullPageDown

func (m *Model) ScrollFullPageDown(viewHeight int)

func (*Model) ScrollFullPageUp

func (m *Model) ScrollFullPageUp(viewHeight int)

func (*Model) ScrollHalfPageDown

func (m *Model) ScrollHalfPageDown(viewHeight int)

func (*Model) ScrollHalfPageUp

func (m *Model) ScrollHalfPageUp(viewHeight int)

func (*Model) SetFileChange

func (m *Model) SetFileChange(file diff.FileChange)

func (*Model) SetSearchState

func (m *Model) SetSearchState(
	isSearching bool,
	getMatches func(hunkIdx, lineIdx int) []MatchRange,
)

func (*Model) SetSelection

func (m *Model) SetSelection(selectedHunk int, isSelected func(hunkIdx int) bool)

func (*Model) SetTagState

func (m *Model) SetTagState(getHunkTags func(hunkIdx int) []SplitTag)

func (*Model) SetVisualState

func (m *Model) SetVisualState(
	lineCursor int,
	isVisualMode bool,
	visualAnchor int,
	isLineSelected func(hunkIdx, lineIdx int) bool,
)

func (*Model) ShowLineNumbers

func (m *Model) ShowLineNumbers() bool

func (*Model) ShowWhitespace

func (m *Model) ShowWhitespace() bool

func (*Model) ToggleLineNumbers

func (m *Model) ToggleLineNumbers()

func (*Model) ToggleSideBySide

func (m *Model) ToggleSideBySide()

func (*Model) ToggleWhitespace

func (m *Model) ToggleWhitespace()

func (*Model) ToggleWordDiff

func (m *Model) ToggleWordDiff()

func (Model) View

func (m Model) View(width, height int, focused bool) string

func (*Model) WordLevelDiff

func (m *Model) WordLevelDiff() bool

type RenderContext

type RenderContext struct {
	Focused         bool
	Height          int
	IsLineSelected  func(hunkIdx, lineIdx int) bool
	IsSearching     bool
	IsSelected      func(hunkIdx int) bool
	IsVisualMode    bool
	GetMatches      func(hunkIdx, lineIdx int) []MatchRange
	LineCursor      int
	SelectedHunk    int
	ShowLineNumbers bool
	ShowWhitespace  bool
	TabWidth        int
	VisualAnchor    int
	Width           int
	WordDiffCache   *WordDiffCache
	WordLevelDiff   bool
}

type SideBySideView

type SideBySideView struct{}

func NewSideBySideView

func NewSideBySideView() *SideBySideView

func (*SideBySideView) Render

func (v *SideBySideView) Render(file *diff.FileChange, ctx RenderContext) string

func (*SideBySideView) SupportsSelection

func (v *SideBySideView) SupportsSelection() bool

type SplitTag

type SplitTag rune

type ViewMode

type ViewMode interface {
	Render(file *diff.FileChange, ctx RenderContext) string
	SupportsSelection() bool
}

type ViewModeType

type ViewModeType string
const (
	ViewModeUnified    ViewModeType = "unified"
	ViewModeSideBySide ViewModeType = "side-by-side"
)

type WordDiffCache

type WordDiffCache struct {
	HunkDiffs map[int]map[int]diff.WordDiffResult
}

Jump to

Keyboard shortcuts

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