ui

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// Reset is an ANSI sequence to reset colors to defaults
	Reset = "\033[39;49m"
	// ResetFg is an ANSI sequence to reset foreground color to default
	ResetFg = "\033[39m"
	// ResetBg is an ANSI sequence to reset background color to default
	ResetBg = "\033[49m"
)

Variables

View Source
var (

	//StreamNameColorizer is a colorizer function for log stream name
	StreamNameColorizer = ColorWrapFunc("+b")
	//TimestampColorizer is a colorizer function for log event timestamp
	TimestampColorizer = ColorWrapFunc("+i")
)

Functions

func Color256Code added in v0.1.2

func Color256Code(styleCode string) string

func Color256Wrap added in v0.1.2

func Color256Wrap(text string, style string) string

func ColorCode

func ColorCode(styleCode string) string

ColorCode returns the ANSI color color code for style.

func ColorRGB

func ColorRGB(fg int, bg int) string

ColorRGB returns the ANSI color code for an RGB color pass -1 if you don't want to change either foreground or background

func ColorWrap added in v0.1.0

func ColorWrap(text string, style string) string

ColorWrap sets the style for the passed string and then resets it to default

func Colorize

func Colorize(pattern *regexp.Regexp, text string) string

Colorize adds ansi color tags to each regex groups if the pattern matches

func ColorizeByColorName added in v0.1.2

func ColorizeByColorName(text string) string

func HighlightLogLevel

func HighlightLogLevel(detectedLevels []string, matches []string, text string) string

HighlightLogLevel applies loglevel-specific background color to the provided text Warning background is applied if logLevel is equal to "WARN" or "WARNING" and Error background is applied for "ERROR" logLevel

func HighlightSelection added in v0.1.0

func HighlightSelection(text string, selection []int, style string) string

HighlightSelection highlights slice of the string with indexes provided in selection with a style

func NameToAnsi256 added in v0.1.2

func NameToAnsi256(name string) int

func RGB

func RGB(r, g, b uint) uint

RGB creates int color from three components

Types

type ColorizerFunc

type ColorizerFunc func(string) string

ColorizerFunc colorizes a string

func ColorFunc

func ColorFunc(color string) ColorizerFunc

ColorFunc returns a function that sets the color for the passed string

func ColorWrapFunc

func ColorWrapFunc(style string) ColorizerFunc

ColorWrapFunc returns a function that sets the style for the passed string and then resets it to default

Jump to

Keyboard shortcuts

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