style

package
v0.0.0-...-00ab8b8 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	FgWhite        = FromBasicFg(color.FgWhite)
	FgLightWhite   = FromBasicFg(color.FgLightWhite)
	FgBlack        = FromBasicFg(color.FgBlack)
	FgBlackLighter = FromBasicFg(color.FgBlack.Light())
	FgCyan         = FromBasicFg(color.FgCyan)
	FgRed          = FromBasicFg(color.FgRed)
	FgGreen        = FromBasicFg(color.FgGreen)
	FgBlue         = FromBasicFg(color.FgBlue)
	FgYellow       = FromBasicFg(color.FgYellow)
	FgMagenta      = FromBasicFg(color.FgMagenta)
	FgDefault      = FromBasicFg(color.FgDefault)

	BgWhite   = FromBasicBg(color.BgWhite)
	BgBlack   = FromBasicBg(color.BgBlack)
	BgRed     = FromBasicBg(color.BgRed)
	BgGreen   = FromBasicBg(color.BgGreen)
	BgYellow  = FromBasicBg(color.BgYellow)
	BgBlue    = FromBasicBg(color.BgBlue)
	BgMagenta = FromBasicBg(color.BgMagenta)
	BgCyan    = FromBasicBg(color.BgCyan)
	BgDefault = FromBasicBg(color.BgDefault)

	// will not print any colour escape codes, including the reset escape code
	Nothing = New()

	AttrUnderline = New().SetUnderline()
	AttrBold      = New().SetBold()

	ColorMap = map[string]struct {
		Foreground TextStyle
		Background TextStyle
	}{
		"default": {FgDefault, BgDefault},
		"black":   {FgBlack, BgBlack},
		"red":     {FgRed, BgRed},
		"green":   {FgGreen, BgGreen},
		"yellow":  {FgYellow, BgYellow},
		"blue":    {FgBlue, BgBlue},
		"magenta": {FgMagenta, BgMagenta},
		"cyan":    {FgCyan, BgCyan},
		"white":   {FgWhite, BgWhite},
	}
)

Functions

func TemplateFuncMapAddColors

func TemplateFuncMapAddColors(m template.FuncMap) template.FuncMap

Types

type Color

type Color struct {
	// contains filtered or unexported fields
}

func NewBasicColor

func NewBasicColor(cl color.Color) Color

func NewRGBColor

func NewRGBColor(cl color.RGBColor) Color

func (Color) IsRGB

func (c Color) IsRGB() bool

func (Color) ToRGB

func (c Color) ToRGB(isBg bool) Color

type Decoration

type Decoration struct {
	// contains filtered or unexported fields
}

func (Decoration) Merge

func (d Decoration) Merge(other Decoration) Decoration

func (*Decoration) SetBold

func (d *Decoration) SetBold()

func (*Decoration) SetReverse

func (d *Decoration) SetReverse()

func (*Decoration) SetStrikethrough

func (d *Decoration) SetStrikethrough()

func (*Decoration) SetUnderline

func (d *Decoration) SetUnderline()

func (Decoration) ToOpts

func (d Decoration) ToOpts() color.Opts

type Sprinter

type Sprinter interface {
	Sprint(a ...interface{}) string
	Sprintf(format string, a ...interface{}) string
}

type TextStyle

type TextStyle struct {

	// making this public so that we can use a type switch to get to the underlying
	// value so we can cache styles. This is very much a hack.
	Style Sprinter
	// contains filtered or unexported fields
}

func FromBasicBg

func FromBasicBg(bg color.Color) TextStyle

func FromBasicFg

func FromBasicFg(fg color.Color) TextStyle

func New

func New() TextStyle

func (TextStyle) MergeStyle

func (b TextStyle) MergeStyle(other TextStyle) TextStyle

func (TextStyle) SetBg

func (b TextStyle) SetBg(color Color) TextStyle

func (TextStyle) SetBold

func (b TextStyle) SetBold() TextStyle

note that our receiver here is not a pointer which means we're receiving a copy of the original TextStyle. This allows us to mutate and return that TextStyle receiver without actually modifying the original.

func (TextStyle) SetFg

func (b TextStyle) SetFg(color Color) TextStyle

func (TextStyle) SetReverse

func (b TextStyle) SetReverse() TextStyle

func (TextStyle) SetStrikethrough

func (b TextStyle) SetStrikethrough() TextStyle

func (TextStyle) SetUnderline

func (b TextStyle) SetUnderline() TextStyle

func (TextStyle) Sprint

func (b TextStyle) Sprint(a ...interface{}) string

func (TextStyle) Sprintf

func (b TextStyle) Sprintf(format string, a ...interface{}) string

Jump to

Keyboard shortcuts

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