diffview

package
v0.0.89 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: Apache-2.0 Imports: 8 Imported by: ? 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 diffview renders semantic OpenAPI changes and source lines for terminal views. Callers own source snapshots, source selection, scrolling, and document comparison.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RenderChange

func RenderChange(ch *changeModel.Change, source Source, width int, styles Styles) string

RenderChange renders a summary followed by bounded physical source context. It never chooses a source document or substitutes coordinates between sides.

func RenderSource

func RenderSource(lines []string, highlight Range, changeType, width int, styles Styles) string

RenderSource renders all physical source lines without wrapping or clipping. It escapes terminal controls. Callers own the viewport and horizontal scrolling.

func RenderSummary

func RenderSummary(ch *changeModel.Change, width int, styles Styles) string

RenderSummary renders a change's action, impact, and detached values. Large values use a marked excerpt; this is not a complete byte diff.

Types

type Range

type Range struct{ Start, End int }

Range identifies inclusive physical source lines, starting at one.

func RangeForChange

func RangeForChange(lines []string, line int, ch *changeModel.Change) Range

RangeForChange locates the changed block in a caller-validated source snapshot.

type Side

type Side uint8

Side identifies the document that owns a source location.

const (
	// Original identifies the document before the change.
	Original Side = iota
	// Candidate identifies the document after the change.
	Candidate
)

type Source

type Source struct {
	Lines []string
	Line  int
	Side  Side
}

Source is source context whose ownership the caller has checked. Line is one-based. A zero Line omits context. External document coordinates must never be paired with root document lines.

type Styles

type Styles struct {
	SelectedRow    lipgloss.Style
	RangeHighlight lipgloss.Style
	AddedRow       lipgloss.Style
	AddedRange     lipgloss.Style
	RemovedRow     lipgloss.Style
	RemovedRange   lipgloss.Style
	Added          lipgloss.Style
	Modified       lipgloss.Style
	Removed        lipgloss.Style
	Breaking       lipgloss.Style
	Grey           lipgloss.Style
	Detail         lipgloss.Style
	YAMLKey        lipgloss.Style
}

Styles supplies terminal styles without imposing an application theme. The zero value renders plain text.

Jump to

Keyboard shortcuts

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