Documentation
¶
Overview ¶
Package printer ports bat's printer module. It renders buffered input lines with bat's decorations (header, grid, line numbers, git change markers, snip separators), syntax-highlighted regions, tab expansion, non-printable notation, line wrapping and line highlighting. SimplePrinter implements the undecorated "cat" path.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type InteractivePrinter ¶
type InteractivePrinter struct {
// contains filtered or unexported fields
}
InteractivePrinter is the decorated, highlighted printer.
func NewInteractive ¶
func NewInteractive(cfg config.Config, theme assets.Theme, changes map[int]decorations.ChangeKind) *InteractivePrinter
NewInteractive builds an InteractivePrinter. changes maps line numbers to git change kinds (may be nil). theme is the resolved highlighting theme.
func (*InteractivePrinter) PrintFooter ¶
func (p *InteractivePrinter) PrintFooter(w io.Writer) error
PrintFooter prints the closing grid border.
func (*InteractivePrinter) PrintHeader ¶
func (p *InteractivePrinter) PrintHeader(w io.Writer, name string, size int64, addPadding bool) error
PrintHeader prints the rule/grid and the filename/size header.
type Line ¶
type Line struct {
Number int
Raw string // line content without trailing newline
HadNewln bool // whether the original line ended with '\n'
Segments []assets.Segment
Highlight bool // draw the line-highlight background
}
Line is a single buffered input line with its precomputed highlight segments.
type Printer ¶
type Printer interface {
PrintHeader(w io.Writer, name string, size int64, addPadding bool) error
PrintSnip(w io.Writer) error
PrintLine(w io.Writer, line Line) error
}
Printer renders headers, footers, snip markers and lines.
type SimplePrinter ¶
type SimplePrinter struct{}
SimplePrinter is the "cat" path: it writes raw line bytes unchanged.
func (*SimplePrinter) PrintFooter ¶
func (p *SimplePrinter) PrintFooter(io.Writer) error