Documentation
¶
Index ¶
- func Run(patches []*diferenco.Patch, opts ...Option) error
- type CursorSetter
- type DefaultStatusBar
- type DiffViewStyle
- type LineStyle
- type Option
- type PatchRenderer
- func (r *PatchRenderer) HunkOffsets() []int
- func (r *PatchRenderer) Render() string
- func (r *PatchRenderer) SetDarkBackground(dark bool)
- func (r *PatchRenderer) SetLineNumbers(enabled bool)
- func (r *PatchRenderer) SetPatch(p *diferenco.Patch)
- func (r *PatchRenderer) SetSize(width, height int)
- func (r *PatchRenderer) SetStyle(style PatchViewStyle)
- func (r *PatchRenderer) SetSyntaxHighlight(enabled bool)
- func (r *PatchRenderer) SetXOffset(offset int)
- func (r *PatchRenderer) SetYOffset(offset int)
- func (r *PatchRenderer) TotalLines() int
- func (r *PatchRenderer) XOffset() int
- func (r *PatchRenderer) YOffset() int
- type PatchView
- type PatchViewStyle
- type PatchesSetter
- type StatusBar
- type SyntaxHighlighter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CursorSetter ¶
type CursorSetter interface {
SetCursor(idx int)
}
CursorSetter is an optional interface for StatusBar implementations that need to be notified when the cursor changes.
type DefaultStatusBar ¶
type DefaultStatusBar struct {
// contains filtered or unexported fields
}
DefaultStatusBar is the default status bar implementation. It displays: status + separator + path + stats + file count.
func NewDefaultStatusBar ¶
func NewDefaultStatusBar() *DefaultStatusBar
NewDefaultStatusBar creates a new DefaultStatusBar.
func (*DefaultStatusBar) Height ¶
func (s *DefaultStatusBar) Height() int
Height returns the height of the status bar (always 1).
func (*DefaultStatusBar) SetCursor ¶
func (s *DefaultStatusBar) SetCursor(idx int)
SetCursor sets the current cursor position.
func (*DefaultStatusBar) SetPatches ¶
func (s *DefaultStatusBar) SetPatches(patches []*diferenco.Patch)
SetPatches sets the patches data.
func (*DefaultStatusBar) SetStyle ¶
func (s *DefaultStatusBar) SetStyle(style PatchViewStyle)
SetStyle sets the style for the status bar.
func (*DefaultStatusBar) View ¶
func (s *DefaultStatusBar) View(width int) string
View renders the status bar.
type DiffViewStyle ¶
type DiffViewStyle struct {
DividerLine LineStyle // Hunk divider line style (@@ -1,3 +1,4 @@)
MissingLine LineStyle // Missing line style (used in Split view)
EqualLine LineStyle // Unchanged line style
InsertLine LineStyle // Inserted line style
DeleteLine LineStyle // Deleted line style
FileName lipgloss.Style // File name style
FileMeta lipgloss.Style // File metadata style
}
DiffViewStyle defines the complete style for DiffView.
func DefaultDarkDiffViewStyle ¶
func DefaultDarkDiffViewStyle() DiffViewStyle
DefaultDarkDiffViewStyle returns the dark theme style.
func DefaultDiffViewStyle ¶
func DefaultDiffViewStyle() DiffViewStyle
DefaultDiffViewStyle automatically selects theme based on terminal background.
func DefaultLightDiffViewStyle ¶
func DefaultLightDiffViewStyle() DiffViewStyle
DefaultLightDiffViewStyle returns the light theme style. Color scheme based on One Light Pro (clear, bright, moderate contrast).
type LineStyle ¶
type LineStyle struct {
LineNumber lipgloss.Style // Line number style
Code lipgloss.Style // Code content style
}
LineStyle defines the style for a single line.
type Option ¶
type Option func(*PatchView)
Option configures the patch view.
func WithListWidth ¶
WithListWidth sets the file list width percentage (default 20).
func WithStatusBar ¶
WithStatusBar sets a custom status bar.
type PatchRenderer ¶
type PatchRenderer struct {
// contains filtered or unexported fields
}
PatchRenderer renders a diferenco.Patch for display. It handles line numbers, syntax highlighting, and horizontal scrolling.
func NewPatchRenderer ¶
func NewPatchRenderer() *PatchRenderer
NewPatchRenderer creates a new PatchRenderer with default style.
func (*PatchRenderer) HunkOffsets ¶
func (r *PatchRenderer) HunkOffsets() []int
HunkOffsets returns the starting line offset for each hunk. This is used for [ and ] navigation between hunks.
func (*PatchRenderer) Render ¶
func (r *PatchRenderer) Render() string
Render renders the patch content for the current viewport.
func (*PatchRenderer) SetDarkBackground ¶
func (r *PatchRenderer) SetDarkBackground(dark bool)
SetDarkBackground sets the terminal background mode.
func (*PatchRenderer) SetLineNumbers ¶
func (r *PatchRenderer) SetLineNumbers(enabled bool)
SetLineNumbers sets whether to show line numbers.
func (*PatchRenderer) SetPatch ¶
func (r *PatchRenderer) SetPatch(p *diferenco.Patch)
SetPatch sets the patch to render.
func (*PatchRenderer) SetSize ¶
func (r *PatchRenderer) SetSize(width, height int)
SetSize sets the rendering area size.
func (*PatchRenderer) SetStyle ¶
func (r *PatchRenderer) SetStyle(style PatchViewStyle)
SetStyle sets the style for rendering.
func (*PatchRenderer) SetSyntaxHighlight ¶
func (r *PatchRenderer) SetSyntaxHighlight(enabled bool)
SetSyntaxHighlight sets whether to enable syntax highlighting.
func (*PatchRenderer) SetXOffset ¶
func (r *PatchRenderer) SetXOffset(offset int)
SetXOffset sets the horizontal scroll offset. Note: Unlike SetYOffset, there's no upper bound because line widths vary and may contain ANSI escape sequences. The render function handles out-of-bounds offsets gracefully by showing empty content.
func (*PatchRenderer) SetYOffset ¶
func (r *PatchRenderer) SetYOffset(offset int)
SetYOffset sets the vertical scroll offset.
func (*PatchRenderer) TotalLines ¶
func (r *PatchRenderer) TotalLines() int
TotalLines returns the total number of lines in the patch.
func (*PatchRenderer) XOffset ¶
func (r *PatchRenderer) XOffset() int
XOffset returns the current horizontal offset.
func (*PatchRenderer) YOffset ¶
func (r *PatchRenderer) YOffset() int
YOffset returns the current vertical offset.
type PatchView ¶
type PatchView struct {
// contains filtered or unexported fields
}
PatchView is an interactive patch navigation view.
func NewPatchView ¶
NewPatchView creates a new PatchView.
type PatchViewStyle ¶
type PatchViewStyle struct {
// File list styles
Addition lipgloss.Style
Deletion lipgloss.Style
Selected lipgloss.Style
// Diff view styles (using LineStyle for background fill)
DiffStyle DiffViewStyle
// UI styles
HeaderBg lipgloss.Style
FileCount lipgloss.Style
Separator lipgloss.Style
PathDisplay lipgloss.Style
FilesTitle lipgloss.Style
// Status styles for header
StatusAdded lipgloss.Style
StatusDeleted lipgloss.Style
StatusRenamed lipgloss.Style
StatusModified lipgloss.Style
}
PatchViewStyle defines the visual style for the patch view.
func DefaultDarkStyle ¶
func DefaultDarkStyle() PatchViewStyle
DefaultDarkStyle returns the dark theme style.
func DefaultLightStyle ¶
func DefaultLightStyle() PatchViewStyle
DefaultLightStyle returns the light theme style.
func DefaultStyle ¶
func DefaultStyle() PatchViewStyle
DefaultStyle returns the default style with auto-detected theme.
type PatchesSetter ¶
PatchesSetter is an optional interface for StatusBar implementations that need access to the patches data.
type SyntaxHighlighter ¶
type SyntaxHighlighter struct {
// contains filtered or unexported fields
}
SyntaxHighlighter is a syntax highlighter.
func NewSyntaxHighlighter ¶
func NewSyntaxHighlighter(filename string, isDark bool) *SyntaxHighlighter
NewSyntaxHighlighter creates a syntax highlighter. filename: used for language detection isDark: whether the background is dark
func (*SyntaxHighlighter) ClearCache ¶
func (h *SyntaxHighlighter) ClearCache()
ClearCache clears the cache.
func (*SyntaxHighlighter) Enabled ¶
func (h *SyntaxHighlighter) Enabled() bool
Enabled returns whether the highlighter is enabled.
func (*SyntaxHighlighter) Highlight ¶
func (h *SyntaxHighlighter) Highlight(source, bgColor string) string
Highlight highlights code. source: original code bgColor: background color (hex format, e.g. "#303a30")