sidebyside

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2026 License: MIT Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package sidebyside renders aligned two-pane terminal diffs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Render

func Render(
	srcFile, dstFile string,
	srcBytes, dstBytes []byte,
	env *serialize.Envelope,
	opts RenderOptions,
	w io.Writer,
) error

Render streams the aligned side-by-side diff of src and dst to w.

func RenderFileBanner

func RenderFileBanner(path string, insertions, deletions, updates int, colorMode bool, w io.Writer) error

RenderFileBanner prints a header with the file path and change stats.

Types

type HunkLayoutKind

type HunkLayoutKind uint8

HunkLayoutKind determines how a hunk or hunk segment is visually structured on screen.

const (
	// HunkLayoutSideBySide renders a standard dual-pane 50/50 split with a central divider.
	HunkLayoutSideBySide HunkLayoutKind = iota
	// HunkLayoutFullWidthInline renders pure single-sided inserts/deletes using the full terminal width.
	HunkLayoutFullWidthInline
)

type RenderOptions

type RenderOptions struct {
	TerminalWidth      int  // Detected or overridden terminal width (default 0 = auto)
	ContextLines       int  // Context lines around hunks (default 3, -1 for full file)
	LineNumbers        bool // Show line number gutters
	Color              bool // Enable TrueColor ANSI escapes
	DisableAnnotations bool // Suppress AST move annotations and badges
	TabWidth           int  // Spaces per tab stop (default 4)
	ForceSideBySide    bool // Prevent falling back to inline diff on narrow screens
	AdaptiveThreshold  int  // Min consecutive single-sided lines to trigger full-width inline hunk (default 6, 0 to disable)
}

RenderOptions defines configuration for side-by-side rendering.

func DefaultOptions

func DefaultOptions() RenderOptions

DefaultOptions returns standard settings for interactive terminals.

type RenderScratch

type RenderScratch struct {
	TabWidth int
	// contains filtered or unexported fields
}

RenderScratch provides reusable highlight index arrays and tab width settings.

func (*RenderScratch) ResolveColHighlights

func (s *RenderScratch) ResolveColHighlights(lineText string, spans []serialize.HighlightSpan, pane string) ([]int, []int)

ResolveColHighlights maps each byte offset in lineText to an action kind and span ID.

func (*RenderScratch) SliceLineToChunks

func (s *RenderScratch) SliceLineToChunks(
	lineText string,
	badgeText string,
	spans []serialize.HighlightSpan,
	targetWidth int,
	pane string,
	isDeleteLine bool,
	colorMode bool,
) [][]byte

SliceLineToChunks formats a single line of text with syntax/action spans into multiple targetWidth display rows (wrapping).

func (*RenderScratch) SliceLineToColumn

func (s *RenderScratch) SliceLineToColumn(
	lineText string,
	badgeText string,
	spans []serialize.HighlightSpan,
	targetWidth int,
	pane string,
	isDeleteLine bool,
	colorMode bool,
	w io.Writer,
) error

SliceLineToColumn formats a single line of text into a single targetWidth column.

Jump to

Keyboard shortcuts

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