style

package
v0.33.4 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package style provide display coloring

Index

Constants

This section is empty.

Variables

View Source
var (
	Default = ""

	Black   = "black"
	Red     = "red"
	Green   = "green"
	Yellow  = "yellow"
	Blue    = "blue"
	Magenta = "magenta"
	Cyan    = "cyan"
	White   = "white"
	Gray    = Of(Dim, White)

	BrightBlack   = "bright-black"
	BrightRed     = "bright-red"
	BrightGreen   = "bright-green"
	BrightYellow  = "bright-yellow"
	BrightBlue    = "bright-blue"
	BrightMagenta = "bright-magenta"
	BrightCyan    = "bright-cyan"
	BrightWhite   = "bright-white"

	BgBlack   = "bg-black"
	BgRed     = "bg-red"
	BgGreen   = "bg-green"
	BgYellow  = "bg-yellow"
	BgBlue    = "bg-blue"
	BgMagenta = "bg-magenta"
	BgCyan    = "bg-cyan"
	BgWhite   = "bg-white"

	BgBrightBlack   = "bg-bright-black"
	BgBrightRed     = "bg-bright-red"
	BgBrightGreen   = "bg-bright-green"
	BgBrightYellow  = "bg-bright-yellow"
	BgBrightBlue    = "bg-bright-blue"
	BgBrightMagenta = "bg-bright-magenta"
	BgBrightCyan    = "bg-bright-cyan"
	BgBrightWhite   = "bg-bright-white"

	Bold       = "bold"
	Dim        = "dim"
	Italic     = "italic"
	Underlined = "underlined"
	Blink      = "blink"
	Inverse    = "inverse"
)
View Source
var Carapace = carapace{
	Value:       Default,
	Description: Gray,
	Error:       Of(Bold, Red),

	KeywordAmbiguous: Yellow,
	KeywordNegative:  Red,
	KeywordPositive:  Green,
	KeywordUnknown:   Gray,

	LogLevelTrace:    Blue,
	LogLevelDebug:    Gray,
	LogLevelInfo:     Green,
	LogLevelWarning:  Yellow,
	LogLevelError:    Magenta,
	LogLevelCritical: Red,
	LogLevelFatal:    Cyan,

	Highlight1: Blue,
	Highlight2: Yellow,
	Highlight3: Magenta,
	Highlight4: Cyan,
	Highlight5: Green,

	Highlight6:  Of(Blue, Dim),
	Highlight7:  Of(Yellow, Dim),
	Highlight8:  Of(Magenta, Dim),
	Highlight9:  Of(Cyan, Dim),
	Highlight10: Of(Green, Dim),

	Highlight11: Bold,
	Highlight12: Of(Bold, Dim),

	FlagArg:      Blue,
	FlagMultiArg: Magenta,
	FlagNoArg:    Default,
	FlagOptArg:   Yellow,
}

Functions

func ForKeyword added in v0.19.0

func ForKeyword(s string, _ Context) string

ForKeyword returns the style for given keyword.

func ForLogLevel added in v0.20.1

func ForLogLevel(s string, _ Context) string

ForLogLevel returns the style for given log level.

func ForPath

func ForPath(path string, sc Context) string

ForPath returns the style for given path

/tmp/locally/reachable/file.txt

func ForPathExt added in v0.19.0

func ForPathExt(path string, sc Context) string

ForPath returns the style for given path by extension only

/tmp/non/existing/file.txt

func Of added in v0.18.2

func Of(s ...string) string

Of combines different styles.

func Register added in v0.19.0

func Register(name string, i interface{})

Register a style configuration

var Carapace = struct {
	Value       string `desc:"default style for values"`
	Description string `desc:"default style for descriptions"`
}{
	Value:       Default,
	Description: Gray,
}

func init() {
	Register("carapace", &Carapace)
}

func SGR added in v0.18.9

func SGR(s string) string

SGR returns the SGR sequence for given style.

func Set added in v0.19.0

func Set(key, value string) error

Set a style

Set("carapace.Value", "bold magenta")

func TrueColor added in v0.18.9

func TrueColor(r, g, b uint8) string

TrueColor returns a 24-bit true color.

func XTerm256Color added in v0.18.9

func XTerm256Color(i uint8) string

XTerm256Color returns a color from the xterm 256-color palette.

Types

type Context added in v0.30.0

type Context interface {
	Abs(s string) (string, error)
	Getenv(key string) string
	LookupEnv(key string) (string, bool)
}

Jump to

Keyboard shortcuts

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