Documentation ¶
Index ¶
- Constants
- type Color
- type Option
- type Palette
- func (p *Palette) Errorf(input string, a ...any) error
- func (p *Palette) Flush() *Palette
- func (p *Palette) Fprint(w io.Writer, input ...any) (n int, err error)
- func (p *Palette) Fprintf(w io.Writer, input string, a ...any) (n int, err error)
- func (p *Palette) Fprintln(w io.Writer, input ...any) (n int, err error)
- func (p *Palette) Print(input ...any) (n int, err error)
- func (p *Palette) Printf(input string, a ...any) (n int, err error)
- func (p *Palette) Println(input ...any) (n int, err error)
- func (p *Palette) SetOptions(opts ...Option) *Palette
- func (p *Palette) Sprint(input ...any) string
- func (p *Palette) Sprintf(input string, a ...any) string
- func (p *Palette) Sprintln(input ...any) string
- type Paletter
- type Special
Constants ¶
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 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 ¶
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 ¶
WithEnabled is a self-referential function to enable/disable palette.
func WithForeground ¶
WithForeground is a self-referential function to set the foreground color.
func WithSpecialEffects ¶
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 ¶
New returns a new palette instance with variable options to set the styling configurations.
func (*Palette) Errorf ¶
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 ¶
Flush resets the Palette options with default values and disables the Palette.
func (*Palette) Fprint ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
SetOptions adds self-referential options to change the properties of Palette.
func (*Palette) Sprint ¶
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.
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.