Documentation
¶
Index ¶
- func Black(s string) string
- func Blue(s string) string
- func Cyan(s string) string
- func Green(s string) string
- func LightBlack(s string) string
- func LightBlue(s string) string
- func LightCyan(s string) string
- func LightGreen(s string) string
- func LightMagenta(s string) string
- func LightRed(s string) string
- func LightWhite(s string) string
- func LightYellow(s string) string
- func Magenta(s string) string
- func Red(s string) string
- func White(s string) string
- func Yellow(s string) string
- type ColorScheme
- type ColorSchemeOption
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LightBlack ¶
func LightGreen ¶
func LightMagenta ¶
func LightWhite ¶
func LightYellow ¶
Types ¶
type ColorScheme ¶
type ColorScheme struct {
// contains filtered or unexported fields
}
ColorScheme formats text with different colors and styles.
Example ¶
fake := console.Fake(
console.WithStdoutTTY(true),
)
cs := colorscheme.New(
colorscheme.WithTTY(fake.IsStdoutTTY),
)
greeting := cs.ColorFunc("green")
fmt.Fprintf(fake, "%s", greeting("Hello, world!"))
// Doubly escape fake stdout and write to real stdout to assert output.
s := strings.ReplaceAll(fake.Stdout().String(), "\x1b", `\x1b`)
fmt.Println(s)
Output: \x1b[0;32mHello, world!\x1b[0m
func New ¶
func New(opts ...ColorSchemeOption) *ColorScheme
New creates a new ColorScheme with options like WithTTY.
type ColorSchemeOption ¶ added in v0.2.0
type ColorSchemeOption func(*ColorScheme)
func WithTTY ¶ added in v0.2.0
func WithTTY(isTTY func() bool) ColorSchemeOption
WithTTY sets a function for ColorScheme to determine if the target Writer represents a TTY and avoid writing terminal sequences.
Click to show internal directories.
Click to hide internal directories.