Help us shape the future of Go! Take the 2026 Go Developer Survey

static

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package static renders diffs to a terminal writer with ANSI colouring.

Index

Constants

This section is empty.

Variables

View Source
var Cyber = Theme{
	Added:       lipgloss.NewStyle().Foreground(lipgloss.Color("#98C379")),
	Removed:     lipgloss.NewStyle().Foreground(lipgloss.Color("#E06C75")),
	Modified:    lipgloss.NewStyle().Foreground(lipgloss.Color("#E5C07B")),
	Unchanged:   lipgloss.NewStyle().Foreground(lipgloss.Color("#3A3A3A")),
	HunkHeader:  lipgloss.NewStyle().Foreground(lipgloss.Color("#00D4FF")),
	FileHeader:  lipgloss.NewStyle().Foreground(lipgloss.Color("#00D4FF")).Bold(true),
	LineNumber:  lipgloss.NewStyle().Foreground(lipgloss.Color("#3A3A3A")),
	StatAdded:   lipgloss.NewStyle().Foreground(lipgloss.Color("#98C379")).Bold(true),
	StatRemoved: lipgloss.NewStyle().Foreground(lipgloss.Color("#E06C75")).Bold(true),
	Banner:      lipgloss.NewStyle().Foreground(lipgloss.Color("#00D4FF")).Bold(true),
}

Cyber is the default dark/cyan theme.

View Source
var Dracula = Theme{
	Added:       lipgloss.NewStyle().Foreground(lipgloss.Color("#50FA7B")),
	Removed:     lipgloss.NewStyle().Foreground(lipgloss.Color("#FF5555")),
	Modified:    lipgloss.NewStyle().Foreground(lipgloss.Color("#F1FA8C")),
	Unchanged:   lipgloss.NewStyle().Foreground(lipgloss.Color("#6272A4")),
	HunkHeader:  lipgloss.NewStyle().Foreground(lipgloss.Color("#BD93F9")),
	FileHeader:  lipgloss.NewStyle().Foreground(lipgloss.Color("#BD93F9")).Bold(true),
	LineNumber:  lipgloss.NewStyle().Foreground(lipgloss.Color("#6272A4")),
	StatAdded:   lipgloss.NewStyle().Foreground(lipgloss.Color("#50FA7B")).Bold(true),
	StatRemoved: lipgloss.NewStyle().Foreground(lipgloss.Color("#FF5555")).Bold(true),
	Banner:      lipgloss.NewStyle().Foreground(lipgloss.Color("#BD93F9")).Bold(true),
}

Dracula theme.

View Source
var Matrix = Theme{
	Added:       lipgloss.NewStyle().Foreground(lipgloss.Color("#00FF41")),
	Removed:     lipgloss.NewStyle().Foreground(lipgloss.Color("#FF3300")),
	Modified:    lipgloss.NewStyle().Foreground(lipgloss.Color("#88FF44")),
	Unchanged:   lipgloss.NewStyle().Foreground(lipgloss.Color("#005500")),
	HunkHeader:  lipgloss.NewStyle().Foreground(lipgloss.Color("#39FF14")),
	FileHeader:  lipgloss.NewStyle().Foreground(lipgloss.Color("#00FF41")).Bold(true),
	LineNumber:  lipgloss.NewStyle().Foreground(lipgloss.Color("#005500")),
	StatAdded:   lipgloss.NewStyle().Foreground(lipgloss.Color("#00FF41")).Bold(true),
	StatRemoved: lipgloss.NewStyle().Foreground(lipgloss.Color("#FF3300")).Bold(true),
	Banner:      lipgloss.NewStyle().Foreground(lipgloss.Color("#00FF41")).Bold(true),
}

Matrix is the green-on-black theme.

View Source
var Nord = Theme{
	Added:       lipgloss.NewStyle().Foreground(lipgloss.Color("#A3BE8C")),
	Removed:     lipgloss.NewStyle().Foreground(lipgloss.Color("#BF616A")),
	Modified:    lipgloss.NewStyle().Foreground(lipgloss.Color("#EBCB8B")),
	Unchanged:   lipgloss.NewStyle().Foreground(lipgloss.Color("#4C566A")),
	HunkHeader:  lipgloss.NewStyle().Foreground(lipgloss.Color("#88C0D0")),
	FileHeader:  lipgloss.NewStyle().Foreground(lipgloss.Color("#88C0D0")).Bold(true),
	LineNumber:  lipgloss.NewStyle().Foreground(lipgloss.Color("#4C566A")),
	StatAdded:   lipgloss.NewStyle().Foreground(lipgloss.Color("#A3BE8C")).Bold(true),
	StatRemoved: lipgloss.NewStyle().Foreground(lipgloss.Color("#BF616A")).Bold(true),
	Banner:      lipgloss.NewStyle().Foreground(lipgloss.Color("#88C0D0")).Bold(true),
}

Nord theme.

Functions

func Boot

func Boot(w io.Writer, fileA, fileB string, opts Options) func(added, removed, modified int, elapsed time.Duration)

Boot prints the diff boot sequence to w. Call before parsing; invoke the returned func after parsing to complete the line.

func Render

func Render(w io.Writer, d *node.Diff, opts Options) error

Render writes the coloured diff to w.

Types

type Options

type Options struct {
	Theme   Theme
	Context int  // lines of context per hunk (default 3)
	Stat    bool // print summary only, no diff body
	NoColor bool
	Quiet   bool
}

Options configures static rendering.

type Theme

type Theme struct {
	Added       lipgloss.Style
	Removed     lipgloss.Style
	Modified    lipgloss.Style // structured diffs: changed value
	Unchanged   lipgloss.Style
	HunkHeader  lipgloss.Style
	FileHeader  lipgloss.Style
	LineNumber  lipgloss.Style
	StatAdded   lipgloss.Style
	StatRemoved lipgloss.Style
	Banner      lipgloss.Style
}

Theme holds lipgloss styles for static diff rendering.

func ResolveTheme

func ResolveTheme(name string) Theme

ResolveTheme returns the named theme, defaulting to Cyber.

Jump to

Keyboard shortcuts

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