commitrender

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: May 27, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package commitrender provides a shared commit-line renderer used by both the commits panel (flat list) and the gitlog panel (graph + progressive columns). Extracting this logic avoids duplicating the same layout, truncation, and highlight behaviour across panels.

Index

Constants

View Source
const AuthorColMaxWidth = 14

AuthorColMaxWidth is the maximum rune-width used for the author column in the log list view. Wider names are truncated to keep the layout compact.

Variables

This section is empty.

Functions

func RenderLine

func RenderLine(p Params) string

RenderLine formats a single commit as a fixed-width terminal line.

Layout (left to right, progressive):

[graph]  subject [(refs)]  [date]  [author]  hash

Columns in square brackets appear only when the corresponding Show* flag is true AND the available width is large enough.

func TruncateOrPad

func TruncateOrPad(s string, width int) string

TruncateOrPad ensures a rendered string fits exactly the given width.

Types

type Params

type Params struct {
	Commit git.Commit
	Width  int

	// IsCursor is true when this row is the cursor row.
	IsCursor bool

	// GraphPrefix is the pre-rendered graph characters for this line.
	// Pass an empty string when graph rendering is not used.
	GraphPrefix string

	Styles Styles

	// ShowRefs enables inline ref display (branch/tag names after the subject).
	ShowRefs bool

	// ShowAuthor makes the author column eligible for display if width allows.
	ShowAuthor bool

	// ShowDate makes the date column eligible for display if width allows.
	ShowDate bool

	// IsSelected highlights the row with a subtler background when true and
	// IsCursor is false (used by the commits panel for the "selected commit"
	// whose files are currently shown).
	IsSelected bool

	// SelectedBg is the background color used when IsSelected is true but
	// IsCursor is false. Ignored when empty.
	SelectedBg string
}

Params configures a single call to RenderLine.

type Styles

type Styles struct {
	Hash    lipgloss.Style
	Date    lipgloss.Style
	Author  lipgloss.Style
	Subject lipgloss.Style
	Ref     lipgloss.Style
	Graph   lipgloss.Style
	Cursor  lipgloss.Style
}

Styles caches lipgloss.Style objects so RenderLine does not allocate new styles on every call (~7,200 allocations/sec at 20 visible commits × 60 fps).

Jump to

Keyboard shortcuts

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