colors

package
v0.0.0-...-041bb18 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// NoColor represents a transparent color.
	NoColor = Color{}

	// EmptyColors represents a transparent Colors.
	EmptyColors = Colors{}
)

Functions

This section is empty.

Types

type Attribute

type Attribute int

Attribute attributes text attributes, such as "bold" and "italic".

const (
	NoAttributes Attribute = 0
	Intense      Attribute = 1 << iota
	Italic
	Underline
	Strike
	Faint
)

func (Attribute) String

func (v Attribute) String() string

type Color

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

Color represents an index color, or a RGB888 color.

func NewIndexColor

func NewIndexColor(index uint8) Color

NewIndexColor creates a new indexed color [0-7].

func (*Color) B

func (c *Color) B() uint8

Index returns the B value [0-255]. Panics if it's not a RGB color.

func (*Color) G

func (c *Color) G() uint8

Index returns the G value [0-255]. Panics if it's not a RGB color.

func (*Color) Index

func (c *Color) Index() uint8

Index returns the color index. Panics if it's not an index color.

func (*Color) IsIndex

func (c *Color) IsIndex() bool

IsIndex returns whether it's an index color or not.

func (*Color) IsNone

func (c *Color) IsNone() bool

IsNone returns whether its NoColor or not.

func (*Color) IsRgb

func (c *Color) IsRgb() bool

IsIndex returns whether it's a RGB color or not.

func (*Color) R

func (c *Color) R() uint8

Index returns the R value [0-255]. Panics if it's not a RGB color.

func (*Color) String

func (c *Color) String() string

String converts a color to a debug string.

type Colors

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

Colors is Attribute + a foreground color + a background color.

func FromString

func FromString(s string) (*Colors, error)

FromString parses a string into a Colors.

func NewColors

func NewColors(fg, bg Color, attrs Attribute) Colors

NewColors creates a new Colors.

func (*Colors) Attributes

func (c *Colors) Attributes() Attribute

Attributes return the attributes of a Colors.

func (*Colors) Bg

func (c *Colors) Bg() Color

Fg returns the background Color of a Colors.

func (*Colors) Fg

func (c *Colors) Fg() Color

Fg returns the foreground Color of a Colors.

func (*Colors) String

func (c *Colors) String() string

func (*Colors) UnmarshalText

func (c *Colors) UnmarshalText(text []byte) error

FromString parses a []byte into a Colors.

Jump to

Keyboard shortcuts

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