diff

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DiffPopup

type DiffPopup struct {
	// Hunk is the diff hunk to display.
	Hunk *providers.DiffHunk

	// Colors defines the color scheme.
	Colors PopupColors

	// TextSize is the size of the text.
	TextSize unit.Sp

	// ShowStageButton controls whether to show the stage button.
	ShowStageButton bool

	// MaxHeight is the maximum height of the popup.
	MaxHeight unit.Dp
	// contains filtered or unexported fields
}

DiffPopup displays a diff hunk with actions to revert or stage changes.

func NewDiffPopup

func NewDiffPopup(hunk *providers.DiffHunk, textSize unit.Sp, popupLine int) *DiffPopup

NewDiffPopup creates a new diff popup for the given hunk.

func (*DiffPopup) Layout

func (p *DiffPopup) Layout(gtx layout.Context, th *material.Theme) layout.Dimensions

Layout renders the diff popup.

func (*DiffPopup) PopupLine

func (p *DiffPopup) PopupLine() int

func (*DiffPopup) Update

func (p *DiffPopup) Update(gtx layout.Context) (PopupEvent, bool)

Update processes events and returns any action taken.

type GitDiff

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

GitDiff is a helper that can be used to parse git diff output. Use the NewGitDiff function to build a new instance to make sure we are dealing with a real git repository.

func NewGitDiff

func NewGitDiff(filePath string) *GitDiff

func (*GitDiff) ParseDiff

func (d *GitDiff) ParseDiff(content []byte) []*providers.DiffHunk

ParseDiff diffs the given buffer content against HEAD. All hunks are marked Staged if the buffer matches the index (staged) version, meaning the user hasn't made further edits beyond what's staged.

type PopupAction

type PopupAction int

PopupAction represents an action that can be performed on a diff hunk.

const (
	// ActionNone indicates no action was taken.
	ActionNone PopupAction = iota
	// DiffActionRevert indicates the user wants to revert the changes.
	ActionRevert
	// ActionStage indicates the user wants to stage the changes.
	ActionStage
	// ActionClose indicates the user closed the popup.
	ActionClose
)

type PopupColors

type PopupColors struct {
	// Background is the popup background color.
	Background gvcolor.Color
	// Border is the popup border color.
	Border gvcolor.Color
	// AddedBackground is the background for added lines.
	AddedBackground gvcolor.Color
	// AddedText is the text color for added lines.
	AddedText gvcolor.Color
	// DeletedBackground is the background for deleted lines.
	DeletedBackground gvcolor.Color
	// DeletedText is the text color for deleted lines.
	DeletedText gvcolor.Color
	// ButtonBackground is the button background color.
	ButtonBackground gvcolor.Color
	// ButtonText is the button text color.
	ButtonText gvcolor.Color
	// HeaderText is the header text color.
	HeaderText gvcolor.Color
}

PopupColors defines the color scheme for the diff popup.

func DefaultPopupColors

func DefaultPopupColors() PopupColors

DefaultPopupColors returns the default color scheme for the diff popup.

type PopupEvent

type PopupEvent struct {
	Action PopupAction
	Hunk   *providers.DiffHunk
}

PopupEvent is emitted when the user interacts with the diff popup.

Jump to

Keyboard shortcuts

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