style

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2024 License: Apache-2.0 Imports: 4 Imported by: 143

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"

	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: Dim,
	Error:       Of(Bold, Red),
	Usage:       Dim,

	KeywordAmbiguous: Yellow,
	KeywordNegative:  Red,
	KeywordPositive:  Green,
	KeywordUnknown:   Of(Dim, White),

	LogLevelTrace:    Blue,
	LogLevelDebug:    Of(Dim, White),
	LogLevelInfo:     Green,
	LogLevelWarning:  Yellow,
	LogLevelError:    Magenta,
	LogLevelCritical: Red,
	LogLevelFatal:    Cyan,

	Highlight1:  Blue,
	Highlight2:  Yellow,
	Highlight3:  Magenta,
	Highlight4:  Cyan,
	Highlight5:  Green,
	Highlight6:  Of(Dim, Blue),
	Highlight7:  Of(Dim, Yellow),
	Highlight8:  Of(Dim, Magenta),
	Highlight9:  Of(Dim, Cyan),
	Highlight10: Of(Dim, Green),
	Highlight11: Bold,
	Highlight12: Of(Dim, Bold),

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

Functions

func ForExtension

func ForExtension(path string, sc Context) string

ForExtension returns the style for given extension

json

func ForKeyword

func ForKeyword(s string, _ Context) string

ForKeyword returns the style for given keyword.

func ForLogLevel

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

func ForPathExt(path string, sc Context) string

ForPath returns the style for given path by extension only

/tmp/non/existing/file.txt

func Of

func Of(s ...string) string

Of combines different styles.

func Parse

func Parse(s string) ui.Style

func Register

func Register(name string, i interface{})

Register a style configuration

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

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

func SGR

func SGR(s string) string

SGR returns the SGR sequence for given style.

func Set

func Set(key, value string) error

Set a style

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

func TrueColor

func TrueColor(r, g, b uint8) string

TrueColor returns a 24-bit true color.

func XTerm256Color

func XTerm256Color(i uint8) string

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

Types

type Context

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