diffview

package
v0.15.7 Latest Latest
Warning

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

Go to latest
Published: May 19, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ActiveHunkIndexForYank added in v0.14.1

func ActiveHunkIndexForYank(section DiffData, navMode NavMode) int

func ChangedLineNumberForYank added in v0.14.1

func ChangedLineNumberForYank(cl ChangedLineLike) int

func FocusedLineSpanForYank added in v0.14.1

func FocusedLineSpanForYank(section DiffData, navMode NavMode) (int, int)

func FocusedLocation added in v0.14.1

func FocusedLocation(section DiffData, navMode NavMode) string

func FocusedYankBody added in v0.14.1

func FocusedYankBody(section DiffData, navMode NavMode) []string

func FormatYankAllContext added in v0.14.1

func FormatYankAllContext(path, loc string, body []string) string

func FormatYankLocation added in v0.14.1

func FormatYankLocation(path, loc string) string

Types

type ChangedLineLike added in v0.14.1

type ChangedLineLike interface {
	Prefix() rune
	OldLineNumber() int
	NewLineNumber() int
	HunkIndexValue() int
	TextValue() string
}

type DiffData added in v0.14.1

type DiffData struct {
	RawLines         []string
	BaseLines        []string
	BaseLineKinds    []diffrender.RowKind
	BaseDisplayToRaw []int
	ViewLines        []string
	ViewLineKinds    []diffrender.RowKind
	DisplayToRaw     []int
	RawToDisplay     []int
	HunkDisplayRange [][2]int
	ChangedDisplay   []int
	Parsed           diffcore.ParsedDiff
	ActiveHunk       int
	ActiveLine       int
	VisualActive     bool
	VisualAnchor     int
}

DiffData contains the complete per-pane diff state: parsed diff, rendered lines/mappings, and active selection/cursor.

func BuildDiffData added in v0.14.1

func BuildDiffData(raw, color string, prev DiffData, sideBySide bool) DiffData

func NewDiffData added in v0.14.1

func NewDiffData() DiffData

func (DiffData) ActiveRawLineIndex added in v0.14.1

func (d DiffData) ActiveRawLineIndex(navMode NavMode) int

func (*DiffData) HasContent added in v0.14.1

func (d *DiffData) HasContent() bool

func (DiffData) HunkDisplayBounds added in v0.14.1

func (d DiffData) HunkDisplayBounds(hunkIdx int) (start int, end int, ok bool)

func (DiffData) VisualLineBounds added in v0.14.1

func (d DiffData) VisualLineBounds() (start, end int)

type DiffSearchMatch added in v0.14.1

type DiffSearchMatch struct {
	DisplayIndex int
	RawIndex     int
}

type FocusedYankError added in v0.14.1

type FocusedYankError string
const (
	FocusedYankErrNoHunk  FocusedYankError = "no hunk selected"
	FocusedYankErrNoLines FocusedYankError = "no lines to yank"
)

type Model

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

Model owns one diff pane state (unstaged or staged), including local search.

func NewModel

func NewModel() Model

func (Model) ActiveRawLineIndex added in v0.14.1

func (m Model) ActiveRawLineIndex() int

func (*Model) ApplySearchMatch added in v0.14.1

func (m *Model) ApplySearchMatch(match search.Match)

func (*Model) BuildFromRaw

func (m *Model) BuildFromRaw(raw, color string)

func (Model) ComputeSearchMatches added in v0.14.1

func (m Model) ComputeSearchMatches(query string) []DiffSearchMatch

func (Model) CurrentSearchCursor added in v0.14.1

func (m Model) CurrentSearchCursor(matches []search.Match) int

func (Model) CurrentSearchMatchIndex added in v0.14.1

func (m Model) CurrentSearchMatchIndex(matches []DiffSearchMatch) int

func (Model) Data

func (m Model) Data() DiffData

func (*Model) DataRef added in v0.14.1

func (m *Model) DataRef() *DiffData

func (*Model) EnableWrap added in v0.14.1

func (m *Model) EnableWrap(enabled bool)

func (*Model) EnsureActiveVisible added in v0.14.1

func (m *Model) EnsureActiveVisible(navMode NavMode)

func (*Model) FocusSearchMatch added in v0.14.1

func (m *Model) FocusSearchMatch(match search.Match)

func (Model) FocusedLocationAndBody added in v0.14.1

func (m Model) FocusedLocationAndBody() (string, []string, FocusedYankError)

func (Model) Init

func (m Model) Init() tea.Cmd

func (Model) IsSideBySide added in v0.14.1

func (m Model) IsSideBySide() bool

func (*Model) JumpBottom added in v0.14.1

func (m *Model) JumpBottom() bool

func (*Model) JumpTop added in v0.14.1

func (m *Model) JumpTop() bool

func (*Model) MoveActive added in v0.14.1

func (m *Model) MoveActive(delta int, allowViewportScroll bool) bool

func (Model) NavMode added in v0.14.1

func (m Model) NavMode() NavMode

func (*Model) Reflow

func (m *Model) Reflow(wrapWidth int)

func (Model) RenderMode added in v0.14.1

func (m Model) RenderMode() RenderMode

func (*Model) RestoreViewportYOffset added in v0.14.1

func (m *Model) RestoreViewportYOffset(y int)

func (*Model) ScrollPage added in v0.14.1

func (m *Model) ScrollPage(delta int)

ScrollPage scrolls the viewport by delta display lines and co-scrolls the active hunk/line to the nearest one at the new display position (vim-style ctrl+d/ctrl+u). In unified mode (HunkDisplayRange/ChangedDisplay are nil) only the viewport scrolls.

func (*Model) ScrollViewport added in v0.14.6

func (m *Model) ScrollViewport(delta int)

func (*Model) Search

func (m *Model) Search() *search.Model

func (*Model) SetData

func (m *Model) SetData(data DiffData)

func (*Model) SetNavMode added in v0.14.1

func (m *Model) SetNavMode(mode NavMode)

func (*Model) SetRenderMode added in v0.14.1

func (m *Model) SetRenderMode(mode RenderMode)

func (*Model) SyncViewport added in v0.14.1

func (m *Model) SyncViewport(width, height int)

func (Model) Update

func (m Model) Update(msg tea.Msg) (Model, tea.Cmd, bool)

func (*Model) Viewport added in v0.14.1

func (m *Model) Viewport() *viewport.Model

func (*Model) VisibleRows added in v0.14.1

func (m *Model) VisibleRows(bodyH int, active bool) []VisibleDiffRow

func (Model) WrapEnabled added in v0.14.1

func (m Model) WrapEnabled() bool
type NavMode int
const (
	NavModeHunk NavMode = iota
	NavModeLine
)

type RenderMode added in v0.14.1

type RenderMode int
const (
	RenderModeUnified RenderMode = iota
	RenderModeSideBySide
)

type SideBySideMapping added in v0.14.1

type SideBySideMapping struct {
	DisplayToRaw     []int
	RawToDisplay     []int
	ChangedDisplay   []int
	HunkDisplayRange [][2]int
}

type VisibleDiffRow added in v0.14.1

type VisibleDiffRow struct {
	DisplayIndex       int
	RawIndex           int
	Text               string
	Kind               diffrender.RowKind
	InActiveHunk       bool
	IsActiveRaw        bool
	IsActiveChangedRaw bool
	OverflowTop        bool
	OverflowBottom     bool
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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