difftree

package
v0.0.0-...-b5bf3c2 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrBreak = fmt.Errorf("break out of callback loop")
View Source
var ErrContinue = fmt.Errorf("continue to next iteration of callback loop")

Functions

This section is empty.

Types

type Chunk

type Chunk struct {
	*gitdiff.TextFragment

	Expanded            ExpansionState
	LineNumber          int
	Parent              *File
	Lines               []*Line
	NonContextLineCount int
	// contains filtered or unexported fields
}

func (*Chunk) ForEachNode

func (chunk *Chunk) ForEachNode(lfn LineFunc) error

func (*Chunk) SetSelection

func (c *Chunk) SetSelection(state SelectionState)

func (*Chunk) ToggleSelection

func (c *Chunk) ToggleSelection()

func (*Chunk) UpdateSelection

func (chunk *Chunk) UpdateSelection()

type ChunkFunc

type ChunkFunc func(*File, *Chunk) error

ChunkFunc is a callback for ForEachNode. Return an error to break out of the sub-loop.

type Commit

type Commit struct {
	Files []*File
	// LineMap maps line numbers (cursor positions) to selection nodes (files, chunks, lines).
	LineMap []Selectable
	// Description includes the commit details, like commit message, etc.
	Description string
}

func ParseCommit

func ParseCommit(r io.Reader) (commit *Commit, err error)

func (*Commit) AsPatchString

func (c *Commit) AsPatchString() string

func (*Commit) ForEachNode

func (c *Commit) ForEachNode(ffn FileFunc, cfn ChunkFunc, lfn LineFunc) error

func (*Commit) GetSelectedFiles

func (c *Commit) GetSelectedFiles() []string

func (*Commit) String

func (commit *Commit) String() string

type ExpansionState

type ExpansionState int
const (
	Collapsed ExpansionState = iota
	Expanded
)

func (ExpansionState) String

func (e ExpansionState) String() string

type File

type File struct {
	*gitdiff.File

	Expanded   ExpansionState
	LineNumber int
	Chunks     []*Chunk
	// contains filtered or unexported fields
}

func (*File) ForEachNode

func (file *File) ForEachNode(cfn ChunkFunc, lfn LineFunc) error

func (*File) Header

func (file *File) Header() string

func (*File) SetSelection

func (f *File) SetSelection(state SelectionState)

func (*File) ToggleSelection

func (f *File) ToggleSelection()

func (*File) UpdateSelection

func (file *File) UpdateSelection()

type FileFunc

type FileFunc func(*File) error

FileFunc is a callback for ForEachNode. Return an error to break out of the loop.

type Line

type Line struct {
	gitdiff.Line

	Parent *Chunk
	// contains filtered or unexported fields
}

func (*Line) SetSelection

func (l *Line) SetSelection(state SelectionState)

func (*Line) ToggleSelection

func (l *Line) ToggleSelection()

type LineFunc

type LineFunc func(*File, *Chunk, *Line) error

LineFunc is a callback for ForEachNode. Return an error to break out of the sub-loop.

type Selectable

type Selectable interface {
	ToggleSelection()
	SetSelection(SelectionState)
}

type SelectionState

type SelectionState int
const (
	Selected SelectionState = iota
	PartiallySelected
	Deselected
)

func (SelectionState) String

func (s SelectionState) String() string

func (*SelectionState) Toggle

func (s *SelectionState) Toggle()

Jump to

Keyboard shortcuts

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