ui

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: May 29, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package ui renders findings and layouts as terminal output (unified / side-by-side / proposed-only diffs and annotated layout). It is the only package that produces user-facing text.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ResolveWidth

func ResolveWidth(out *os.File) int

ResolveWidth returns the default per-side column width for side-by-side diff, derived from the terminal attached to out (falling back to $COLUMNS, then 80).

func WantColor

func WantColor(colorize common.Colorize, out *os.File) bool

WantColor resolves the -color mode ("auto"|"always"|"never") against out and the environment. In "auto" mode it honors NO_COLOR (https://no-color.org); an explicit -color=always still wins, per that convention.

Types

type Printer

type Printer struct {
	Out   io.Writer
	Err   io.Writer // error stream (defaults to os.Stderr if nil)
	Color bool
	Width int   // per-side column width for side-by-side diffs
	Theme Theme // zero value resolves to DefaultTheme
}

Printer renders to Out using the given color/width settings.

func (*Printer) RenderFindings

func (p *Printer) RenderFindings(findings []common.Finding, style common.DiffStyle) int

RenderFindings renders each finding in the chosen diff style. Returns the count.

func (*Printer) RenderJSON added in v0.7.0

func (p *Printer) RenderJSON(version string, inspect bool, findings []common.Finding, layouts []common.Layout, keepTags bool)

RenderJSON emits a structured JSON document for findings or layouts. When keepTags is false, struct field tags are omitted from inspect-mode layouts (mirroring the text inspect behavior); diff-mode findings carry tags inside `original` / `proposed` only when the upstream align phase preserved them.

func (*Printer) RenderLayouts

func (p *Printer) RenderLayouts(layouts []common.Layout, verbose, keepTags bool) int

RenderLayouts renders each struct layout. Returns the count.

func (*Printer) RenderSummary added in v0.6.0

func (p *Printer) RenderSummary(structs int, bytesSaved int64)

RenderSummary writes a one-line diff-mode summary to Out. The "Summary:" label is bold when color is on; counts are pluralized.

type Style added in v0.6.1

type Style struct {
	// contains filtered or unexported fields
}

Style is the appearance of one semantic role: an optional foreground color plus attributes. The zero value is "no styling" and renders text unchanged.

type Theme added in v0.6.0

type Theme struct {
	Header  Style // finding header / inspect "type X struct {" line
	Added   Style // "+" diff lines / added side cells
	Removed Style // "-" diff lines / removed side cells
	Meta    Style // column titles, divider, layout note, "-- assume" marker
	Padding Style // inspect padding comment / "_" padding line
	Label   Style // the -summary "Summary:" label
}

Theme maps semantic roles to styles. The zero value resolves to DefaultTheme (see Printer.theme), which reproduces the historical palette.

func DefaultTheme added in v0.6.0

func DefaultTheme() Theme

DefaultTheme is the historical palette: bold cyan header, green added, red removed/padding, dim meta, bold label. termenv renders these as the same visual output the hand-rolled SGR constants produced.

func ThemeByName added in v0.6.0

func ThemeByName(name string) (Theme, bool)

ThemeByName returns a built-in theme and whether it was found.

Jump to

Keyboard shortcuts

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