Documentation ¶
Overview ¶
Package color provides color-based types and helpers.
Index ¶
- Constants
- func Copy(s Style, dst io.Writer, src io.Reader) (int64, error)
- func Enabled() bool
- func Fprint(dst io.Writer, s Style, args ...any) (int, error)
- func Fprintf(dst io.Writer, s Style, msg string, args ...any) (int, error)
- func Fprintln(dst io.Writer, s Style, args ...any) (int, error)
- func Print(s Style, args ...any)
- func Printf(s Style, msg string, args ...any)
- func Println(s Style, args ...any)
- func Sprint(s Style, args ...any) string
- func Sprintf(s Style, msg string, args ...any) string
- func Sprintln(s Style, args ...any) string
- func Wrap(s Style, msg string) string
- func WrapN(s Style, msgs ...string) string
- type Color
- func (c Color) Copy(dst io.Writer, src io.Reader) (int64, error)
- func (c Color) Escape() string
- func (c Color) Fprint(w io.Writer, args ...any) (int, error)
- func (c Color) Fprintf(w io.Writer, msg string, args ...any) (int, error)
- func (c Color) Fprintln(w io.Writer, args ...any) (int, error)
- func (c Color) Print(args ...any)
- func (c Color) Printf(msg string, args ...any)
- func (c Color) Println(args ...any)
- func (c Color) Reset() string
- func (c Color) Sprint(args ...any) string
- func (c Color) Sprintf(msg string, args ...any) string
- func (c Color) Sprintln(args ...any) string
- func (c Color) String() string
- func (c Color) Wrap(str string) string
- func (c Color) WrapN(strs ...string) string
- type Style
Constants ¶
View Source
const Version = "v0.1.1"
Version is the current version of the package.
Variables ¶
This section is empty.
Functions ¶
func Enabled ¶
func Enabled() bool
Enabled returns whether color is enabled based on terminal settings.
Types ¶
type Color ¶
type Color uint8
A Color is a terminal color.
const ( Reset Color = iota Bold Faint Italic Underline BlinkSlow BlinkRapid ReverseVideo Concealed CrossedOut )
Style colors.
Foreground colors.
const ( FgHiBlack Color = iota + 90 FgHiRed FgHiGreen FgHiYellow FgHiBlue FgHiMagenta FgHiCyan FgHiWhite )
Foreground high-intensity colors.
Background colors.
const ( BgHiBlack Color = iota + 100 BgHiRed BgHiGreen BgHiYellow BgHiBlue BgHiMagenta BgHiCyan BgHiWhite )
Background high-intensity colors.
func (Color) Fprintf ¶
Fprintf prints msg and args to w as in fmt.Fprintf, but wrapped in c.
func (Color) Fprintln ¶
Fprintln prints args to w as in fmt.Fprintln, but wrapped in c.
func (Color) Sprintf ¶
Sprintf returns a string containing msg and args as in fmt.Sprintf, but wrapped in c.
func (Color) Sprintln ¶
Sprintln returns a string containing args as in fmt.Sprintln, but wrapped in c.
type Style ¶
type Style interface { Copy(io.Writer, io.Reader) (int64, error) Escape() string Fprint(io.Writer, ...any) (int, error) Fprintf(io.Writer, string, ...any) (int, error) Fprintln(io.Writer, ...any) (int, error) Print(...any) Printf(string, ...any) Println(...any) Reset() string Sprint(...any) string Sprintf(string, ...any) string Sprintln(...any) string String() string Wrap(string) string WrapN(...string) string }
A Style styles text.
Click to show internal directories.
Click to hide internal directories.