palette

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2023 License: MIT Imports: 3 Imported by: 1

Documentation

Index

Constants

View Source
const (

	//Black.
	Black Color = 0
	//Red.
	Red Color = 1
	//Green.
	Green Color = 2
	//Yellow.
	Yellow Color = 3
	//Blue.
	Blue Color = 4
	//Magenta.
	Magenta Color = 5
	// Cyan.
	Cyan Color = 6
	//White.
	White Color = 7

	//BrightBlack.
	BrightBlack Color = 8
	//BrightRed.
	BrightRed Color = 9
	//BrightGreen.
	BrightGreen Color = 10
	//BrightYellow.
	BrightYellow Color = 11
	//BrightBlue.
	BrightBlue Color = 12
	//BrightMagenta.
	BrightMagenta Color = 13
	//Bright Cyan.
	BrightCyan Color = 14
	//BrightWhite.
	BrightWhite Color = 15

	//Reset.
	Reset Special = 0
	//Bold.
	Bold Special = 1
	//Dim.
	Dim Special = 2
	//Italic.
	Italic Special = 3
	//Underline.
	Underline Special = 4
	//SlowBlink.
	SlowBlink Special = 5
	//Hidden.
	Hidden Special = 8
	//Strikethrough.
	Strikethrough Special = 9
	//DefaultFont.
	DefaultFont Special = 10
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Color

type Color int32

Color is a wrapper.

type Option

type Option func(p *Palette)

Option is a self-referential function to make palette modular and extensible. Read more about self-referential function here: https://commandcenter.blogspot.com/2014/01/self-referential-functions-and-design.html

func WithBackground

func WithBackground(bg Color) Option

WithBackground is a self-referential function to set the background color.

func WithDefaults

func WithDefaults() Option

WithDefaults is a self-referential function to set the default styles.

func WithEnabled

func WithEnabled(e bool) Option

WithEnabled is a self-referential function to enable/disable palette.

func WithForeground

func WithForeground(fg Color) Option

WithForeground is a self-referential function to set the foreground color.

func WithSpecialEffects

func WithSpecialEffects(effects []Special) Option

WithSpecialEffects is a self-referential function to set the special effect styles.

type Palette

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

Implements the Paletter interface.

func New

func New(opts ...Option) *Palette

New returns a new palette instance with variable options to set the styling configurations.

func (*Palette) Errorf

func (p *Palette) Errorf(input string, a ...any) error

Errorf formats according to a format specifier and decorates the input with the styling configurations. It returns the string as a value that satisfies error.

func (*Palette) Flush

func (p *Palette) Flush() *Palette

Flush resets the Palette options with default values and disables the Palette.

func (*Palette) Fprint

func (p *Palette) Fprint(w io.Writer, input ...any) (n int, err error)

Fprint formats using the default formats and decorates the input with the styling configurations. Finally writes to w. Spaces are added between operands when neither is a string. It returns the number of bytes written and any write error encountered.

func (*Palette) Fprintf

func (p *Palette) Fprintf(w io.Writer, input string, a ...any) (n int, err error)

Fprintf formats according to a format specifier and decorates the input with the styling configurations. Finally writes to w. Spaces are added between operands when neither is a string. It returns the number of bytes written and any write error encountered.

func (*Palette) Fprintln

func (p *Palette) Fprintln(w io.Writer, input ...any) (n int, err error)

Fprintln formats using the default formats for its operands and decorates the input with the styling configurations. Finally writes to w. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.

func (*Palette) Print

func (p *Palette) Print(input ...any) (n int, err error)

Print formats using the default formats for its operands and decorates the input with the styling configurations. Finally writes to standard output. Spaces are added between operands when neither is a string. It returns the number of bytes written and any write error encountered.

func (*Palette) Printf

func (p *Palette) Printf(input string, a ...any) (n int, err error)

Printf formats according to a format specifier and decorates the input with the styling configurations. Finally writes to standard output. It returns the number of bytes written and any write error encountered.

func (*Palette) Println

func (p *Palette) Println(input ...any) (n int, err error)

Println formats using the default formats for its operands and decorates the input with the styling configurations. Finally writes to standard output. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.

func (*Palette) SetOptions

func (p *Palette) SetOptions(opts ...Option) *Palette

SetOptions adds self-referential options to change the properties of Palette.

func (*Palette) Sprint

func (p *Palette) Sprint(input ...any) string

Sprint formats using the default formats for its operands and decorates the input with the styling configurations before returning the resulting string. Spaces are added between operands when neither is a string.

func (*Palette) Sprintf

func (p *Palette) Sprintf(input string, a ...any) string

Printf formats according to a format specifier and decorates the input with the styling configurations before returning the resulting string.

func (*Palette) Sprintln

func (p *Palette) Sprintln(input ...any) string

Sprintln formats using the default formats for its operands and decorates the input with the styling configurations before returning the resulting string. Spaces are always added between operands and a newline is appended.

type Paletter

type Paletter interface {
	// Wrapper on fmt.Errorf
	Errorf(string, ...any) error

	// Wrapper on fmt.Fprint
	Fprint(io.Writer, ...any) (n int, err error)

	// Wrapper on fmt.Fprintf
	Fprintf(io.Writer, string, ...any) (n int, err error)

	// Wrapper on fmt.Fprintln
	Fprintln(io.Writer, ...any) (n int, err error)

	// Wrapper on fmt.Print
	Print(...any) (n int, err error)

	// Wrapper on fmt.Printf
	Printf(string, ...any) (n int, err error)

	// Wrapper on fmt.Println
	Println(...any) (n int, err error)

	// Wrapper on fmt.Sprint
	Sprint(...any) string

	// Wrapper on fmt.Sprintf
	Sprintf(string, ...any) string

	// Wrapper on fmt.Sprintln
	Sprintln(...any) string
}

Paletter interface.

type Special

type Special int32

Special is a wrapper.

Jump to

Keyboard shortcuts

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