sidepane

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Code generated by enum generator; DO NOT EDIT.

Code generated by enum generator; DO NOT EDIT.

Index

Constants

This section is empty.

Variables

View Source
var (
	// zero value sentinel
	DirectionUnknown = Direction{/* contains filtered or unexported fields */}
	// forward / next
	DirectionNext = Direction{/* contains filtered or unexported fields */}
	// backward / previous
	DirectionPrev = Direction{/* contains filtered or unexported fields */}
)

Public constants for direction values

View Source
var (
	// zero value sentinel
	MotionUnknown = Motion{/* contains filtered or unexported fields */}
	// single step up
	MotionUp = Motion{/* contains filtered or unexported fields */}
	// single step down
	MotionDown = Motion{/* contains filtered or unexported fields */}
	// page up — uses count[0] from variadic
	MotionPageUp = Motion{/* contains filtered or unexported fields */}
	// page down — uses count[0] from variadic
	MotionPageDown = Motion{/* contains filtered or unexported fields */}
	// jump to first entry
	MotionFirst = Motion{/* contains filtered or unexported fields */}
	// jump to last entry
	MotionLast = Motion{/* contains filtered or unexported fields */}
)

Public constants for motion values

View Source
var DirectionNames = []string{
	"Unknown",
	"Next",
	"Prev",
}

DirectionNames contains all possible enum names

DirectionValues contains all possible enum values

View Source
var MotionNames = []string{
	"Unknown",
	"Up",
	"Down",
	"PageUp",
	"PageDown",
	"First",
	"Last",
}

MotionNames contains all possible enum names

MotionValues contains all possible enum values

Functions

func DirectionIter

func DirectionIter() func(yield func(Direction) bool)

DirectionIter returns a function compatible with Go 1.23's range-over-func syntax. It yields all Direction values in declaration order. Example:

for v := range DirectionIter() {
    // use v
}

func MotionIter

func MotionIter() func(yield func(Motion) bool)

MotionIter returns a function compatible with Go 1.23's range-over-func syntax. It yields all Motion values in declaration order. Example:

for v := range MotionIter() {
    // use v
}

Types

type Direction

type Direction struct {
	// contains filtered or unexported fields
}

Direction is the exported type for the enum

func MustDirection

func MustDirection(v string) Direction

MustDirection is like ParseDirection but panics if string is invalid

func ParseDirection

func ParseDirection(v string) (Direction, error)

ParseDirection converts string to direction enum value. Parsing is always case-insensitive.

func (Direction) Index

func (e Direction) Index() int

Index returns the underlying integer value

func (Direction) MarshalText

func (e Direction) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler

func (Direction) String

func (e Direction) String() string

func (*Direction) UnmarshalText

func (e *Direction) UnmarshalText(text []byte) error

UnmarshalText implements encoding.TextUnmarshaler

type FileTree

type FileTree struct {
	// contains filtered or unexported fields
}

FileTree manages the list of changed files grouped by directory.

func NewFileTree

func NewFileTree(entries []diff.FileEntry) *FileTree

NewFileTree builds a FileTree from a list of changed file entries. handles entries == nil gracefully, returning a valid empty *FileTree.

func (*FileTree) EnsureVisible

func (ft *FileTree) EnsureVisible(height int)

EnsureVisible adjusts offset so the cursor is within the visible range of given height.

func (*FileTree) FileStatus

func (ft *FileTree) FileStatus(path string) diff.FileStatus

FileStatus returns the git change status for the given file path.

func (*FileTree) FilterActive

func (ft *FileTree) FilterActive() bool

FilterActive returns true when the file tree is showing only annotated files.

func (*FileTree) HasFile

func (ft *FileTree) HasFile(dir Direction) bool

HasFile returns true if there is a file entry in the given direction from the current cursor position (no wrap-around).

func (*FileTree) Move

func (ft *FileTree) Move(m Motion, count ...int)

Move navigates the cursor according to the given motion. count is variadic: page motions use count[0] for the page size, non-page motions ignore count entirely. Missing count for page motions defaults to 1 (single step), which is harmless.

func (*FileTree) Rebuild

func (ft *FileTree) Rebuild(entries []diff.FileEntry)

Rebuild rebuilds the file tree from new entries in-place. preserves reviewed map (pruned to files still present), resets cursor/offset, positions cursor on first file entry, and preserves filter state. entries are rebuilt from all files regardless of filter flag; call RefreshFilter afterward when FilterActive returns true.

func (*FileTree) RefreshFilter

func (ft *FileTree) RefreshFilter(annotatedFiles map[string]bool)

RefreshFilter rebuilds the filtered tree if the filter is active, preserving cursor position.

func (*FileTree) Render

func (ft *FileTree) Render(r FileTreeRender) string

Render produces the file tree display string, showing only entries visible within the given height. it adjusts the internal offset so the cursor stays within the visible window.

func (*FileTree) ReviewedCount

func (ft *FileTree) ReviewedCount() int

ReviewedCount returns the number of files marked as reviewed.

func (*FileTree) SelectByPath

func (ft *FileTree) SelectByPath(path string) bool

SelectByPath sets the cursor to the file entry matching the given path. returns true if the file was found and cursor moved, false otherwise.

func (*FileTree) SelectedFile

func (ft *FileTree) SelectedFile() string

SelectedFile returns the full path of the currently selected file, or empty string if a directory is selected or entries are empty.

func (*FileTree) StepFile

func (ft *FileTree) StepFile(dir Direction)

StepFile moves to the next or previous file entry, wrapping around at ends.

func (*FileTree) ToggleFilter

func (ft *FileTree) ToggleFilter(annotatedFiles map[string]bool)

ToggleFilter switches between showing all files and only annotated files.

func (*FileTree) ToggleReviewed

func (ft *FileTree) ToggleReviewed(path string)

ToggleReviewed toggles the reviewed state of the given file path.

func (*FileTree) TotalFiles

func (ft *FileTree) TotalFiles() int

TotalFiles returns the count of original file paths (before filtering).

type FileTreeRender

type FileTreeRender struct {
	Width     int
	Height    int
	Annotated map[string]bool
	Resolver  Resolver
	Renderer  Renderer
}

FileTreeRender holds parameters for FileTree.Render.

type Motion

type Motion struct {
	// contains filtered or unexported fields
}

Motion is the exported type for the enum

func MustMotion

func MustMotion(v string) Motion

MustMotion is like ParseMotion but panics if string is invalid

func ParseMotion

func ParseMotion(v string) (Motion, error)

ParseMotion converts string to motion enum value. Parsing is always case-insensitive.

func (Motion) Index

func (e Motion) Index() int

Index returns the underlying integer value

func (Motion) MarshalText

func (e Motion) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler

func (Motion) String

func (e Motion) String() string

func (*Motion) UnmarshalText

func (e *Motion) UnmarshalText(text []byte) error

UnmarshalText implements encoding.TextUnmarshaler

type Renderer

type Renderer interface {
	FileStatusMark(status diff.FileStatus) string
	FileReviewedMark() string
	FileAnnotationMark() string
}

Renderer is what sidepane needs for compound ANSI rendering (FileTree only — TOC doesn't use it). satisfied by *style.Renderer via ui's styleRenderer interface.

type Resolver

type Resolver interface {
	Style(k style.StyleKey) lipgloss.Style
	Color(k style.ColorKey) style.Color
}

Resolver is what sidepane needs for style lookups. satisfied by *style.Resolver via ui's styleResolver interface.

type TOC

type TOC struct {
	// contains filtered or unexported fields
}

TOC manages the markdown table-of-contents navigation pane.

func ParseTOC

func ParseTOC(lines []diff.DiffLine, filename string) *TOC

ParseTOC scans diff lines for markdown headers and builds a TOC. headers inside fenced code blocks (```) are excluded. fence tracking is CommonMark-compliant: closing fence must use the same character with at least the same length as the opening fence. returns nil when no headers are found.

func (*TOC) CurrentLineIdx

func (t *TOC) CurrentLineIdx() (int, bool)

CurrentLineIdx returns the diff line index of the entry at the current cursor position. returns ok=false when entries are empty or cursor is out of range.

func (*TOC) EnsureVisible

func (t *TOC) EnsureVisible(height int)

EnsureVisible adjusts offset so the cursor is within the visible range of given height.

func (*TOC) Move

func (t *TOC) Move(m Motion, count ...int)

Move navigates the cursor according to the given motion. count is variadic: page motions use count[0] for the page size, non-page motions ignore count entirely. Missing count for page motions defaults to 1 (single step), which is harmless.

func (*TOC) NumEntries

func (t *TOC) NumEntries() int

NumEntries returns the number of TOC entries.

func (*TOC) Render

func (t *TOC) Render(r TOCRender) string

Render produces the TOC display string with indentation by level. the highlighted entry uses FileSelected style in both modes: when TOC is focused it highlights the cursor, when diff is focused it highlights the active section.

func (*TOC) SyncCursorToActiveSection

func (t *TOC) SyncCursorToActiveSection()

SyncCursorToActiveSection sets cursor to activeSection when activeSection >= 0. no-op when activeSection == -1 (no active section).

func (*TOC) UpdateActiveSection

func (t *TOC) UpdateActiveSection(diffCursor int)

UpdateActiveSection finds the nearest entry with lineIdx <= diffCursor and sets activeSection. sets activeSection back to -1 when no entry matches, preserving the sentinel contract.

type TOCRender

type TOCRender struct {
	Width    int
	Height   int
	Focused  bool
	Resolver Resolver
}

TOCRender holds parameters for TOC.Render.

Jump to

Keyboard shortcuts

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