terminal

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: MIT, MIT Imports: 2 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package terminal holds low-level output primitives: color schemas and incremental VT100 redraws.

Index

Constants

View Source
const (
	BlackColor = iota
	RedColor
	GreenColor
	YellowColor
	BlueColor
	MagentaColor
	CyanColor
	WhiteColor
)
View Source
const NoColor = -1

NoColor disables coloring for a slot.

View Source
const ResetSequence = "\033[0m"

ResetSequence clears all ANSI attributes.

Variables

This section is empty.

Functions

func CalculateIncrementalUpdate

func CalculateIncrementalUpdate(output *bufio.Writer, linesBefore []string, linesAfter []string)

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

func GetColorSequence(code int) string

GetColorSequence returns the ANSI escape for the color code.

func GetColoredText

func GetColoredText(color int, text string) string

GetColoredText wraps text in the color code, or returns it unchanged for NoColor.

Types

type ColorSchema

type ColorSchema struct {
	SuccessColor int
	FailureColor int
	NeutralColor int
}

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).

Jump to

Keyboard shortcuts

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