Documentation ¶
Overview ¶
Package color provides ANSI color codes for output formatting.
Index ¶
- func Available() bool
- func Black(input ...any) string
- func Blue(input ...any) string
- func Bold(input ...any) string
- func Cyan(input ...any) string
- func Default(input ...any) string
- func Gray(input ...any) string
- func Green(input ...any) string
- func Italic(input ...any) string
- func Overload(ansi []byte, input string) string
- func Purple(input ...any) string
- func Red(input ...any) string
- func White(input ...any) string
- func Yellow(input ...any) string
- type ANSI
- func (c *ANSI) Black(input ...any) *ANSI
- func (c *ANSI) Blue(input ...any) *ANSI
- func (c *ANSI) Bold(input ...any) *ANSI
- func (c *ANSI) Cyan(input ...any) *ANSI
- func (c *ANSI) Default(input ...any) *ANSI
- func (c *ANSI) Gray(input ...any) *ANSI
- func (c *ANSI) Green(input ...any) *ANSI
- func (c *ANSI) Italic(input ...any) *ANSI
- func (c *ANSI) Overload(ansi []byte, input string) *ANSI
- func (c *ANSI) Print()
- func (c *ANSI) Purple(input ...any) *ANSI
- func (c *ANSI) Red(input ...any) *ANSI
- func (c *ANSI) String() string
- func (c *ANSI) White(input ...any) *ANSI
- func (c *ANSI) Write()
- func (c *ANSI) Yellow(input ...any) *ANSI
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Available ¶
func Available() bool
Available checks if the terminal has a TTY (teletypewriter) available and returns a boolean value indicating if the system's output buffer is capable of color output.
func Black ¶
Black applies the black color to the input string(s) and returns it as a raw string. If the current operating system is not Windows and ci is false, it adds the color code before and the reset code after each input string.
func Blue ¶
Blue applies the blue color to the input string(s) and returns it as a raw string. If the current operating system is not Windows and ci is false, it adds the color code before and the reset code after each input string.
func Bold ¶
Bold applies the bold style to the input string(s) and returns it as a raw string. If the current operating system is not Windows and ci is false, it adds the style code before and the reset code after each input string.
func Cyan ¶
Cyan applies the cyan color to the input string(s) and returns it as a raw string. If the current operating system is not Windows and ci is false, it adds the color code before and the reset code after each input string.
func Default ¶
Default applies default color to the input string(s) and returns it as a raw string. If the current operating system is not Windows and ci is false, it adds the color code before and the reset code after each input string.
func Gray ¶
Gray applies the gray color to the input string(s) and returns it as a raw string. If the current operating system is not Windows and ci is false, it adds the color code before and the reset code after each input string.
func Green ¶
Green applies the green color to the input string(s) and returns it as a raw string. If the current operating system is not Windows and ci is false, it adds the color code before and the reset code after each input string.
func Italic ¶
Italic applies the italic style to the input string(s) and returns it as a raw string. If the current operating system is not Windows and ci is false, it adds the style code before and the reset code after each input string.
func Overload ¶
Overload constructs an ANSI string with the provided ANSI Escape characters and the input string.
func Purple ¶
Purple applies the purple color to the input string(s) and returns it as a raw string. If the current operating system is not Windows and ci is false, it adds the color code before and the reset code after each input string.
func Red ¶
Red applies the red color to the input string(s) and returns it as a raw string. If the current operating system is not Windows and ci is false, it adds the color code before and the reset code after each input string.
Types ¶
type ANSI ¶
type ANSI string
func (*ANSI) Black ¶
Black applies the black color to the input string(s) and returns it as an ANSI string. It uses the Black() function from the ANSI package to convert the input to black color. If the current operating system is not Windows and ci is false, it adds the color code before and the reset code after each input string.
func (*ANSI) Blue ¶
Blue applies the blue color to the input string(s) and returns it as an ANSI string. It uses the Blue() function from the ANSI package to convert the input to blue color. If the current operating system is not Windows and ci is false, it adds the color code before and the reset code after each input string.
func (*ANSI) Bold ¶
Bold applies the bold style to the input string(s) and returns it as an ANSI string. It uses the Bold() function from the ANSI package to convert the input to bold style. If the current operating system is not Windows and ci is false, it adds the style code before and the reset code after each input string.
func (*ANSI) Cyan ¶
Cyan applies the cyan color to the input string(s) and returns it as an ANSI string. It uses the Cyan() function from the ANSI package to convert the input to cyan color. If the current operating system is not Windows and ci is false, it adds the color code before and the reset code after each input string.
func (*ANSI) Default ¶
Default applies the default color to the input string(s) and returns it as an ANSI string. It uses the Default() function from the ANSI package to convert the input to default color. If the current operating system is not Windows and ci is false, it adds the color code before and the reset code after each input string.
func (*ANSI) Gray ¶
Gray applies the gray color to the input string(s) and returns it as an ANSI string. It uses the Gray() function from the ANSI package to convert the input to gray color. If the current operating system is not Windows and ci is false, it adds the color code before and the reset code after each input string.
func (*ANSI) Green ¶
Green applies the green color to the input string(s) and returns it as an ANSI string. It uses the Green() function from the ANSI package to convert the input to green color. If the current operating system is not Windows and ci is false, it adds the color code before and the reset code after each input string.
func (*ANSI) Italic ¶
Italic applies the italic style to the input string(s) and returns it as an ANSI string. It uses the Italic() function from the ANSI package to convert the input to italic style. If the current operating system is not Windows and ci is false, it adds the style code before and the reset code after each input string.
func (*ANSI) Overload ¶
Overload allows passing ANSI Escape characters directly. It constructs an ANSI string with the provided ANSI Escape characters and the input string.
func (*ANSI) Print ¶
func (c *ANSI) Print()
Print writes the ANSI string to the output buffer without a newline character.
func (*ANSI) Purple ¶
Purple applies the purple color to the input string(s) and returns it as an ANSI string. It uses the Purple() function from the ANSI package to convert the input to purple color. If the current operating system is not Windows and ci is false, it adds the color code before and the reset code after each input string.
func (*ANSI) Red ¶
Red applies the red color to the input string(s) and returns it as an ANSI string. It uses the Red() function from the ANSI package to convert the input to red color. If the current operating system is not Windows and ci is false, it adds the color code before and the reset code after each input string.
func (*ANSI) White ¶
White applies the white color to the input string(s) and returns it as an ANSI string. It uses the White() function from the ANSI package to convert the input to white color. If the current operating system is not Windows and ci is false, it adds the color code before and the reset code after each input string.
func (*ANSI) Write ¶
func (c *ANSI) Write()
Write writes the ANSI string to the output buffer with a newline character.
func (*ANSI) Yellow ¶
Yellow applies the yellow color to the input string(s) and returns it as an ANSI string. It uses the Yellow() function from the ANSI package to convert the input to yellow color. If the current operating system is not Windows and the ci variable is false, it adds the color code before and the reset code after each input string.