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 ¶
- func ResolveWidth(out *os.File) int
- func WantColor(colorize common.Colorize, out *os.File) bool
- type Printer
- func (p *Printer) RenderFindings(findings []common.Finding, style common.DiffStyle) int
- func (p *Printer) RenderJSON(version string, inspect bool, findings []common.Finding, ...)
- func (p *Printer) RenderLayouts(layouts []common.Layout, verbose, keepTags bool) int
- func (p *Printer) RenderSummary(structs int, bytesSaved int64)
- type Style
- type Theme
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ResolveWidth ¶
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).
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 ¶
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 ¶
RenderLayouts renders each struct layout. Returns the count.
func (*Printer) RenderSummary ¶ added in v0.6.0
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
ThemeByName returns a built-in theme and whether it was found.