Documentation
¶
Overview ¶
Package terminal holds low-level output primitives: color schemas and incremental VT100 redraws.
Index ¶
- Constants
- func CalculateIncrementalUpdate(output *bufio.Writer, linesBefore []string, linesAfter []string)
- func CalculateIncrementalUpdateMaxLines(output *bufio.Writer, linesBefore []string, linesAfter []string, maxLines int)
- func GetColorSequence(code int) string
- func GetColoredText(color int, text string) string
- type ColorSchema
Constants ¶
const ( BlackColor = iota RedColor GreenColor YellowColor BlueColor MagentaColor CyanColor WhiteColor )
const NoColor = -1
NoColor disables coloring for a slot.
const ResetSequence = "\033[0m"
ResetSequence clears all ANSI attributes.
Variables ¶
This section is empty.
Functions ¶
func CalculateIncrementalUpdate ¶
CalculateIncrementalUpdate redraws linesBefore into linesAfter with the minimal escape traffic: common prefix skipped, changed lines replaced in place, appended lines printed, removed tail erased.
func CalculateIncrementalUpdateMaxLines ¶
func CalculateIncrementalUpdateMaxLines(output *bufio.Writer, linesBefore []string, linesAfter []string, maxLines int)
CalculateIncrementalUpdateMaxLines behaves like CalculateIncrementalUpdate but first drops lines above maxLines, so bounded terminals never scroll.
func GetColorSequence ¶
GetColorSequence returns the ANSI escape for the color code.
func GetColoredText ¶
GetColoredText wraps text in the color code, or returns it unchanged for NoColor.
Types ¶
type ColorSchema ¶
ColorSchema maps outcomes to ANSI color codes (see color constants).
func DefaultColorSchema ¶
func DefaultColorSchema() *ColorSchema
DefaultColorSchema paints success green, failure red, neutral yellow.
func NoColorSchema ¶
func NoColorSchema() *ColorSchema
NoColorSchema disables all coloring (NO_COLOR, dumb, piped).