sidebyside

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: MIT Imports: 12 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 CountLineStats added in v0.14.0

func CountLineStats(srcBytes, dstBytes []byte, env *serialize.Envelope, showStyleChanges bool, significantWhitespace bool) (int, int, int)

CountLineStats returns the inserted, deleted, and updated line counts for the diff banner.

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, annotation string, colorMode bool, w io.Writer) error

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

Types

type HunkLayoutKind

type HunkLayoutKind uint8

HunkLayoutKind determines how a hunk is visually structured on screen.

const (
	// HunkLayoutDualColumn renders a standard dual-pane 50/50 split with a central divider.
	HunkLayoutDualColumn HunkLayoutKind = iota
	// HunkLayoutSingleColumnRight renders pure insertions across the full terminal width.
	HunkLayoutSingleColumnRight
	// HunkLayoutSingleColumnLeft renders pure deletions across the full terminal width.
	HunkLayoutSingleColumnLeft
)

func ClassifyHunk added in v0.10.0

func ClassifyHunk(
	h renderutil.Interval,
	filteredPairs []serialize.LineAlignmentPair,
	isPairChanged []bool,
	leftSpansByLine, rightSpansByLine map[int][]serialize.HighlightSpan,
	forceSBS bool,
) HunkLayoutKind

ClassifyHunk picks dual-column if both sides changed, or single-column for pure additions or deletions.

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
	SuppressHunkFallbackAnnotation bool // Stops hunk headers from repeating the fallback tag when the file banner already shows it
	TabWidth                       int  // Spaces per tab stop (default 4)
	ForceSideBySide                bool // Disable hybrid single-column layout and force 50/50 dual-column view
	ShowStyleChanges               bool // Display changes that only differ in whitespace or formatting
}

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 wraps a reusable line slicer and terminal tab width configuration.

func (*RenderScratch) SliceLineToChunks

func (s *RenderScratch) SliceLineToChunks(
	lineText string,
	badgeText string,
	spans []serialize.HighlightSpan,
	targetWidth int,
	lineCtx renderutil.LineContext,
	padToTargetWidth bool,
	colorMode bool,
	badgeColor ...int,
) [][]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,
	lineCtx renderutil.LineContext,
	padToTargetWidth bool,
	colorMode bool,
	w io.Writer,
	badgeColor ...int,
) 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