Documentation
¶
Overview ¶
Package ui implements the bubbletea TUI for revdiff — a diff reviewer with inline annotations.
The package centers on a single Model struct that implements bubbletea's Model interface. Model methods are split across multiple files by concern area, all operating on the same struct:
- model.go — struct definition, NewModel, Init, Update, handleKey dispatch, view toggles
- view.go — View rendering, status bar, ANSI color helpers
- handlers.go — modal key handlers: help overlay, enter/esc dispatch, discard confirmation, filter toggle, mark-reviewed, file-or-search navigation
- loaders.go — async file/blame loading (tea.Cmd producers), loaded-message handlers, data preparation (stats, filter, skip-dividers)
- diffview.go — diff content rendering: line styling, gutters (line numbers, blame), syntax-highlight integration, search-match highlighting, annotation rendering within diff
- diffnav.go — navigation dispatchers for diff/tree/TOC panes, cursor movement, hunk navigation (including cross-file), viewport synchronization, horizontal scroll
- collapsed.go — collapsed diff mode: hides removed lines, shows modified markers, per-hunk expansion, delete-only placeholders
- filetree.go — file tree sidebar component with cursor, scroll, and selection
- annotate.go — annotation input lifecycle: start, save, cancel, delete (line and file level), cursor-viewport coordination, annotation key map
- annotlist.go — annotation list overlay for cross-file annotation browsing
- mdtoc.go — markdown table-of-contents sidebar for single-file markdown review
- search.go — incremental search: input handling, match computation, navigation
- styles.go — lipgloss style definitions, theme color integration
The key interfaces consumed by Model are Renderer (provides changed files and diffs), SyntaxHighlighter (provides ANSI-highlighted lines), and Blamer (provides git blame data). All three are defined in this package and implemented externally.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Colors ¶
type Colors struct {
Accent string // active pane borders, dir names
Border string // inactive pane borders
Normal string // file entries, context lines
Muted string // divider lines, status bar
SelectedFg string // selected file text
SelectedBg string // selected file background
Annotation string // annotation text and markers
CursorFg string // diff cursor indicator foreground
CursorBg string // diff cursor line background
AddFg string // added line foreground
AddBg string // added line background
RemoveFg string // removed line foreground
RemoveBg string // removed line background
ModifyFg string // modified line foreground (collapsed mode)
ModifyBg string // modified line background (collapsed mode)
TreeBg string // file tree pane background
DiffBg string // diff pane background
StatusFg string // status bar foreground
StatusBg string // status bar background
SearchFg string // search match foreground
SearchBg string // search match background
}
Colors holds hex color values (#rrggbb) for TUI rendering.
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model is the top-level bubbletea model for revdiff.
func NewModel ¶
func NewModel(renderer Renderer, store *annotation.Store, highlighter SyntaxHighlighter, cfg ModelConfig) Model
NewModel creates a new Model with the given renderer, store, highlighter and configuration.
func (Model) Discarded ¶
Discarded returns true when the user chose to discard annotations and quit.
func (Model) Store ¶
func (m Model) Store() *annotation.Store
Store returns the annotation store for reading results after quit.
type ModelConfig ¶
type ModelConfig struct {
Ref string
Staged bool
TreeWidthRatio int
TabWidth int // number of spaces per tab character
NoColors bool // disable all colors including syntax highlighting
NoStatusBar bool // hide the status bar
NoConfirmDiscard bool // skip confirmation prompt when discarding annotations
Wrap bool // enable line wrapping
Collapsed bool // start in collapsed diff mode
CrossFileHunks bool // allow [ and ] to jump across file boundaries
LineNumbers bool // show line numbers in diff gutter
ShowBlame bool // show blame gutter on startup when available
Only []string // show only these files (match by exact path or path suffix)
WorkDir string // working directory for resolving absolute --only paths
Keymap *keymap.Keymap // custom key bindings (nil uses defaults)
LoadUntracked func() ([]string, error) // fetches untracked files; nil when unavailable
Blamer Blamer // optional blame provider (nil when git unavailable)
Colors Colors
}
ModelConfig holds configuration options for NewModel.