Documentation
¶
Index ¶
- func FormatDiff(rawDiff string, width int, styles Styles) string
- func FormatDiffSummary(rawDiff string) string
- func HighlightDiff(rawDiff string) string
- func HighlightDiffLine(content, filePath string) string
- type ColumnSide
- type CommentMsg
- type DiffActionMsg
- type DiffMode
- type DiffRefreshedMsg
- type LineMetadata
- type Model
- func (m *Model) ClickAt(y int)
- func (m Model) Diff() string
- func (m Model) FileCount() int
- func (m *Model) ForceSetDiff(diff string)
- func (m Model) Init() tea.Cmd
- func (m Model) Mode() DiffMode
- func (m Model) RawDiffLines() int
- func (m *Model) ScrollBy(delta int)
- func (m Model) ScrollPercent() float64
- func (m *Model) SetDiff(diff string)
- func (m *Model) SetEditor(editor string)
- func (m *Model) SetFocused(f bool)
- func (m *Model) SetSize(w, h int)
- func (m *Model) SetWorkDir(dir string)
- func (m Model) Update(msg tea.Msg) (Model, tea.Cmd)
- func (m Model) View() string
- type SendCommentsMsg
- type SideBySideLine
- type Styles
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatDiff ¶
FormatDiff formats a raw unified diff string for display (thin wrapper).
func FormatDiffSummary ¶
FormatDiffSummary formats a short summary of changes.
func HighlightDiff ¶
HighlightDiff applies syntax highlighting to an entire diff.
func HighlightDiffLine ¶
HighlightDiffLine applies syntax highlighting to a diff line's content.
Types ¶
type ColumnSide ¶
type ColumnSide int
ColumnSide represents which column is focused in side-by-side view.
const ( ColumnNew ColumnSide = iota // right side, default ColumnOld // left side )
type CommentMsg ¶
type CommentMsg struct {
FilePath string
LineNumber int
LineType git.DiffLineType
Side ColumnSide // which column the comment was made on
Comment string
}
CommentMsg is a single pending comment (used internally).
type DiffActionMsg ¶
type DiffActionMsg int
DiffActionMsg represents an action to perform in the diff view.
const ( DiffActionComment DiffActionMsg = iota DiffActionEditComment DiffActionSendComments )
type DiffRefreshedMsg ¶
type DiffRefreshedMsg struct {
Diff string
}
DiffRefreshedMsg is emitted by manual refresh (r key) to force a rebuild.
type LineMetadata ¶
type LineMetadata struct {
FilePath string
LineNumber int // source line number from hunk header parsing
LineType git.DiffLineType
IsHeader bool // border, hunk header, or file list decoration line
// Side-by-side column info
OldLineNumber int // left column line number (0 = blank)
OldLineType git.DiffLineType // left column line type
NewLineNumber int // right column line number (0 = blank)
NewLineType git.DiffLineType // right column line type
}
LineMetadata holds metadata about a rendered line for cursor/comment support.
func FormatDiffWithMetadata ¶
func FormatDiffWithMetadata(rawDiff string, width int, styles Styles) ([]string, []LineMetadata)
FormatDiffWithMetadata formats a raw unified diff and returns per-line rendered strings plus parallel metadata for cursor/comment tracking.
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model is the diff view component.
func (*Model) ClickAt ¶
ClickAt moves the cursor to the line at the given Y offset within the viewport's visible area (0 = first visible line). Maps the display line to a source line, skipping injected comment lines.
func (*Model) ForceSetDiff ¶
ForceSetDiff sets the diff content and always rebuilds, even if unchanged. Used for manual refresh to guarantee visual feedback.
func (Model) RawDiffLines ¶
RawDiffLines returns the number of lines in the raw diff.
func (*Model) ScrollBy ¶
ScrollBy scrolls the viewport by delta lines and adjusts the cursor to stay within the visible area. Maps display indices back to source lines.
func (Model) ScrollPercent ¶
ScrollPercent returns the current scroll position.
func (*Model) SetWorkDir ¶
SetWorkDir sets the working directory for diff computation.
type SendCommentsMsg ¶
type SendCommentsMsg struct {
Comments []CommentMsg
}
SendCommentsMsg is emitted when the user presses ctrl+s to send all pending comments.
type SideBySideLine ¶
type SideBySideLine struct {
OldNum int // 0 = blank/filler
OldContent string // syntax-highlighted
OldType git.DiffLineType
NewNum int
NewContent string
NewType git.DiffLineType
}
SideBySideLine holds a paired old/new line for side-by-side rendering.
type Styles ¶
type Styles struct {
AddedLine lipgloss.Style
RemovedLine lipgloss.Style
AddedLineBg lipgloss.Style
RemovedLineBg lipgloss.Style
ContextLine lipgloss.Style
HunkHeader lipgloss.Style
FileHeader lipgloss.Style
LineNumber lipgloss.Style
Border lipgloss.Style
FocusedBorder lipgloss.Style
Title lipgloss.Style
Empty lipgloss.Style
CursorLine lipgloss.Style
SearchMatch lipgloss.Style
SearchMatchCurrent lipgloss.Style
FileListItem lipgloss.Style
FileListItemAdded lipgloss.Style
FileListItemModified lipgloss.Style
FileListItemDeleted lipgloss.Style
FileBorder lipgloss.Style
AddedPrefix lipgloss.Style
RemovedPrefix lipgloss.Style
Separator lipgloss.Style
BlankCell lipgloss.Style
ColumnFocus lipgloss.Style
CommentIndicator lipgloss.Style
CommentBorder lipgloss.Style
CommentText lipgloss.Style
CommentAuthor lipgloss.Style
ScrollFilled lipgloss.Style
ScrollEmpty lipgloss.Style
ColumnDim lipgloss.Style
ChangeBarAdded lipgloss.Style
ChangeBarRemoved lipgloss.Style
HunkSeparator lipgloss.Style
}
Styles holds all diff view styles.
func DefaultStyles ¶
func DefaultStyles(p theme.ColorPalette) Styles
DefaultStyles returns the default diff view styles.