ui

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RenderBinaryFile

func RenderBinaryFile(styles Styles, width int) string

RenderBinaryFile renders a placeholder for binary files.

func RenderDiff

func RenderDiff(parsed ParsedDiff, filename string, styles Styles, t theme.Theme, width int) string

RenderDiff renders parsed diff lines into a styled string.

func RenderNewFile

func RenderNewFile(content, filename string, styles Styles, t theme.Theme, width int) string

RenderNewFile renders file content as an all-added diff (for untracked files).

func RenderNewFileSplit added in v1.1.0

func RenderNewFileSplit(content, filename string, styles Styles, t theme.Theme, width int) string

RenderNewFileSplit renders untracked file content in split layout (all-added on right).

func RenderSplitDiff added in v1.1.0

func RenderSplitDiff(parsed ParsedDiff, filename string, styles Styles, t theme.Theme, width int) string

RenderSplitDiff renders parsed diff in side-by-side layout.

Types

type DiffLine

type DiffLine struct {
	Type    DiffLineType
	Content string
	OldNum  int // -1 if N/A
	NewNum  int // -1 if N/A
}

DiffLine is a single parsed line from a unified diff.

type DiffLineType

type DiffLineType int

DiffLineType classifies a line in a unified diff.

const (
	LineContext DiffLineType = iota
	LineAdded
	LineRemoved
	LineHunkHeader
	LineFileHeader
)

type LogModel

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

LogModel is the Bubble Tea model for the commit log browser.

func NewLogModel

func NewLogModel(repo *git.Repo, styles Styles, t theme.Theme) LogModel

NewLogModel creates the log browser model.

func (LogModel) Init

func (m LogModel) Init() tea.Cmd

func (LogModel) Update

func (m LogModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (LogModel) View

func (m LogModel) View() string

type Model

type Model struct {
	SelectedFile string // set on "open in editor" action, read after Run()
	// contains filtered or unexported fields
}

Model is the main Bubble Tea model for the diff viewer.

func NewModel

func NewModel(
	repo *git.Repo,
	cfg config.Config,
	changes []git.FileChange,
	untracked []string,
	styles Styles,
	t theme.Theme,
	stagedOnly bool,
	ref string,
) Model

NewModel creates the main diff viewer model.

func (Model) Init

func (m Model) Init() tea.Cmd

func (*Model) StartInCommitMode

func (m *Model) StartInCommitMode()

StartInCommitMode sets the model to open directly in commit mode.

func (Model) Update

func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update dispatches messages to the appropriate mode handler.

func (Model) View

func (m Model) View() string

View renders the full UI.

type ParsedDiff

type ParsedDiff struct {
	Lines  []DiffLine
	Binary bool
}

ParsedDiff is the result of parsing a raw unified diff.

func ParseDiff

func ParseDiff(raw string) ParsedDiff

ParseDiff parses raw unified diff output into structured lines.

type SplitLine added in v1.1.0

type SplitLine struct {
	Left  *DiffLine // nil = blank padding
	Right *DiffLine // nil = blank padding
}

SplitLine pairs left (old) and right (new) sides for side-by-side display.

func PairLines added in v1.1.0

func PairLines(lines []DiffLine) []SplitLine

PairLines converts unified diff lines into paired split lines.

type Styles

type Styles struct {
	// File list
	FileItem     lipgloss.Style
	FileSelected lipgloss.Style
	StagedIcon   lipgloss.Style

	// File status colors
	StatusModified  lipgloss.Style
	StatusAdded     lipgloss.Style
	StatusDeleted   lipgloss.Style
	StatusRenamed   lipgloss.Style
	StatusUntracked lipgloss.Style

	// Diff
	DiffAdded          lipgloss.Style
	DiffRemoved        lipgloss.Style
	DiffAddedBg        lipgloss.Style // bg-only, for padding highlighted lines
	DiffRemovedBg      lipgloss.Style // bg-only, for padding highlighted lines
	DiffContext        lipgloss.Style
	DiffHunkHeader     lipgloss.Style
	DiffLineNum        lipgloss.Style
	DiffLineNumAdded   lipgloss.Style
	DiffLineNumRemoved lipgloss.Style

	// Chrome
	HeaderBar lipgloss.Style
	StatusBar lipgloss.Style
	HelpKey   lipgloss.Style
	HelpDesc  lipgloss.Style
	CardBg    lipgloss.Style

	// Commit input
	CommitInput lipgloss.Style

	// Accent
	Accent lipgloss.Style
}

Styles holds all lipgloss styles derived from a theme.

func NewStyles

func NewStyles(t theme.Theme) Styles

NewStyles creates styles from a theme.

Jump to

Keyboard shortcuts

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