Documentation
¶
Index ¶
- Constants
- type Model
- func (m *Model) ClearCache()
- func (m *Model) ClearSelection()
- func (m *Model) CurrentFilePath() string
- func (m *Model) DebugSelection() (anchor, head Point, band [2]int, active bool)
- func (m *Model) EndSelection() (string, bool)
- func (m *Model) ExtendSelection(p Point)
- func (m *Model) GutterCol() int
- func (m *Model) HasDir() bool
- func (m *Model) HasFile() bool
- func (m *Model) HasSelection() bool
- func (m *Model) Height() int
- func (m Model) Init() tea.Cmd
- func (m *Model) IsSelecting() bool
- func (m *Model) RootDiffStats() (int64, int64)
- func (m *Model) ScrollBottom()
- func (m *Model) ScrollDown(lines int)
- func (m *Model) ScrollTop()
- func (m *Model) ScrollUp(lines int)
- func (m *Model) SetContent(s string)
- func (m *Model) SetDarkBackground(isDark bool) tea.Cmd
- func (m Model) SetDirPatch(dirPath string, files []*gitdiff.File) (Model, tea.Cmd)
- func (m Model) SetFilePatch(file *gitdiff.File) (Model, tea.Cmd)
- func (m *Model) SetPreamble(preamble string)
- func (m *Model) SetSideBySide(sideBySide bool) tea.Cmd
- func (m *Model) SetSize(width, height int) tea.Cmd
- func (m *Model) StartSelection(p Point)
- func (m *Model) TotalLineCount() int
- func (m Model) Update(msg tea.Msg) (Model, tea.Cmd)
- func (m Model) View() string
- func (m *Model) Width() int
- func (m *Model) YOffset() int
- type Point
Constants ¶
const DirHeaderHeight = 3
DirHeaderHeight is the height of the header band rendered above the diff viewport. Exported so callers translating mouse coordinates into content rows (see tui.go's diffPanePoint) can skip past it.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Model ¶
func (*Model) ClearCache ¶
func (m *Model) ClearCache()
func (*Model) ClearSelection ¶
func (m *Model) ClearSelection()
ClearSelection drops all selection state.
func (*Model) CurrentFilePath ¶
CurrentFilePath returns the path of the currently displayed file, or "" if none.
func (*Model) DebugSelection ¶
DebugSelection exposes the current selection's anchor/head/band for tests. Only intended for diagnostics — not part of any public contract.
func (*Model) EndSelection ¶
EndSelection finalizes an active selection. If the head never moved away from the anchor it returns ("", false) with the selection cleared. Otherwise it returns (selectedText, true) and leaves the finalized highlight in place until the next event clears it.
func (*Model) ExtendSelection ¶
ExtendSelection moves the selection head to p, clamping p.Col into the active colBand. The line axis is never clamped — vertical drag spans the full content. No-op when no drag is active.
func (*Model) GutterCol ¶
GutterCol returns the detected side-by-side divider column, or -1 for unified mode / undetected.
func (*Model) HasSelection ¶
HasSelection reports whether a finalized non-empty selection exists.
func (*Model) Height ¶
Height returns the diff viewport's visible row count (excluding the dir-header band). Mouse-edge logic uses this to detect dragging past the pane edge.
func (*Model) IsSelecting ¶
IsSelecting reports whether a drag is currently in progress.
func (*Model) RootDiffStats ¶
func (*Model) ScrollBottom ¶
func (m *Model) ScrollBottom()
ScrollBottom scrolls the viewport to the bottom.
func (*Model) ScrollDown ¶
ScrollDown scrolls the viewport down by the given number of lines.
func (*Model) SetContent ¶
SetContent loads a string directly into the underlying viewport, bypassing the delta render pipeline. Intended for tests that need scrollable content without invoking the external delta binary.
func (Model) SetDirPatch ¶
func (*Model) SetPreamble ¶
SetPreamble stores the preamble text (e.g. commit metadata from git show).
func (*Model) SetSideBySide ¶
SetSideBySide updates the diff view mode and re-renders.
func (*Model) StartSelection ¶
StartSelection begins a new selection anchored at p. Derives colBand from p.Col, m.gutterCol, and the detected per-side content columns. The band excludes the leading border, line numbers, and post-LN border on whichever side the click landed.
Lines without the standard side-by-side layout — hunk-header boxes ("60: struct …"), filename decorations, separators — opt out of side- specific clamping so the user can select content that lives outside the post-line-number borders. Sets active=true, has=false. Any prior selection is replaced.
func (*Model) TotalLineCount ¶
TotalLineCount returns the number of content lines currently loaded into the viewport.
type Point ¶
Point identifies a position within the rendered diff content.
Col is a *visual column* — the same coordinate space as paneX and ansi.Cut/lipgloss.Width — never a rune index or byte offset. Callers must translate any rune-index-derived value into visual columns before storing it in a Point.