gitdiff

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package gitdiff implements the diff viewer panel for the grut TUI. It displays file diffs with syntax-highlighted additions and deletions, supporting both inline (unified) and side-by-side view modes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GitDiff

type GitDiff struct {
	panels.BasePanel
	// contains filtered or unexported fields
}

GitDiff is the diff viewer panel. It displays file diffs with syntax-highlighted additions/deletions in inline or side-by-side format.

func New

func New(gitClient git.StatusReader, th *theme.Theme) *GitDiff

New creates a new GitDiff panel. gitClient may be nil (the panel will show an error until a client is available). th may be nil (fallback colors are used).

func (*GitDiff) Init

func (d *GitDiff) Init(ctx context.Context) tea.Cmd

Init implements panels.Panel.

func (*GitDiff) KeyBindings

func (d *GitDiff) KeyBindings() []panels.KeyBinding

KeyBindings implements panels.Panel.

func (*GitDiff) SetActionsCfg

func (d *GitDiff) SetActionsCfg(cfg config.ActionsConfig)

SetActionsCfg stores the right-click context menu configuration.

func (*GitDiff) SetDiffs

func (d *GitDiff) SetDiffs(diffs []git.FileDiff)

SetDiffs directly injects diff data without a git client, primarily for testing. It resets scroll and rebuilds rendered lines.

func (*GitDiff) SetSize

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

SetSize implements panels.Panel. Overrides BasePanel to trigger a re-render when dimensions change (side-by-side needs width info).

func (*GitDiff) Title

func (d *GitDiff) Title() string

Title implements panels.Panel. Returns a dynamic title showing the current file, or "gitdiff" when no file is selected.

func (*GitDiff) Update

func (d *GitDiff) Update(msg tea.Msg) (panels.Panel, tea.Cmd)

Update implements panels.Panel. It handles diff-related messages and keyboard events for scrolling, navigation, and view mode toggling.

func (*GitDiff) View

func (d *GitDiff) View(width, height int) string

View implements panels.Panel. It renders the diff content into the given width×height area.

Jump to

Keyboard shortcuts

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