internal

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 16, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Default = Color(iota)

	Black
	Red
	Green
	Yellow
	Blue
	Magenta
	Cyan
	Gray

	BoldBlack
	BoldRed
	BoldGreen
	BoldYellow
	BoldBlue
	BoldMagenta
	BoldCyan
	BoldGray
)

Variables

View Source
var (
	TmplColorFuncMap        template.FuncMap
	TmplColorFuncMapNonTerm template.FuncMap
)
View Source
var (
	FgColors   []string
	BgColors   []string
	ResetColor = "\x1b[39;49;22m"
)
View Source
var ColorNames = map[string]Color{
	"black":   Black,
	"red":     Red,
	"green":   Green,
	"yellow":  Yellow,
	"blue":    Blue,
	"magenta": Magenta,
	"cyan":    Cyan,
	"gray":    Gray,

	"black_b":   BoldBlack,
	"red_b":     BoldRed,
	"green_b":   BoldGreen,
	"yellow_b":  BoldYellow,
	"blue_b":    BoldBlue,
	"magenta_b": BoldMagenta,
	"cyan_b":    BoldCyan,
	"gray_b":    BoldGray,
}

ColorNames names can be used for generic color function. quick foreground color function with same name is also availalbe in template

View Source
var (
	TmplFuncMap = template.FuncMap{
		"cap":  Capped,
		"pad":  Padding,
		"join": Join,
	}
)

Functions

func Capped

func Capped(cap int, v interface{}) string

Capped truncate given value to specified length if cap > 0: with tailing "..." if truncated if cap < 0: with middle "..." if truncated

func Colored

func Colored(s interface{}, colorNames ...string) string

Colored takes 0, 1, or 2 color names when present, they should be in order of fgName, bgName

func ColoredWithCode

func ColoredWithCode(s interface{}, fg, bg Color) string

func ColoredWithName

func ColoredWithName(s interface{}, fgName, bgName string) string

func DebugShowcase

func DebugShowcase()

func Join

func Join(sep string, values ...interface{}) string

func MakeQuickColorFunc

func MakeQuickColorFunc(fg Color) func(s interface{}) string

func NoopColored

func NoopColored(v interface{}, _ ...string) interface{}

func NoopQuickColor

func NoopQuickColor(v interface{}) interface{}

func Padding

func Padding(padding int, v interface{}) string

Padding example: `{{padding -6 value}}` "{{padding 10 value}}"

func Sprint

func Sprint(val interface{}) string

Types

type Color

type Color uint8

Jump to

Keyboard shortcuts

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