Documentation ¶
Overview ¶
Package textoutput offers a simple way to use vt100 and output colored text
Index ¶
- Variables
- type CharAttribute
- type TextOutput
- func (o *TextOutput) ColorOff() string
- func (o *TextOutput) ColorOn(attribute1, attribute2 int) string
- func (o *TextOutput) DarkBlue(s string) string
- func (o *TextOutput) DarkCyan(s string) string
- func (o *TextOutput) DarkGray(s string) string
- func (o *TextOutput) DarkGreen(s string) string
- func (o *TextOutput) DarkPurple(s string) string
- func (o *TextOutput) DarkRed(s string) string
- func (o *TextOutput) DarkTags(colors ...string) string
- func (o *TextOutput) DarkYellow(s string) string
- func (o *TextOutput) Disable()
- func (o *TextOutput) DisableColors()
- func (o *TextOutput) Disabled() bool
- func (o *TextOutput) Enable()
- func (o *TextOutput) EnableColors()
- func (o *TextOutput) Enabled() bool
- func (o *TextOutput) Err(msg string)
- func (o *TextOutput) ErrExit(msg string)
- func (o *TextOutput) Extract(s string) []CharAttribute
- func (o *TextOutput) Fprint(w io.Writer, msg ...interface{})
- func (o *TextOutput) Fprintf(w io.Writer, msg ...interface{})
- func (o *TextOutput) Fprintln(w io.Writer, msg ...interface{})
- func (o *TextOutput) InterfaceTags(colors ...interface{}) string
- func (o *TextOutput) IsEnabled() bool
- func (o *TextOutput) LightBlue(s string) string
- func (o *TextOutput) LightCyan(s string) string
- func (o *TextOutput) LightGreen(s string) string
- func (o *TextOutput) LightPurple(s string) string
- func (o *TextOutput) LightRed(s string) string
- func (o *TextOutput) LightTags(colors ...string) string
- func (o *TextOutput) LightYellow(s string) string
- func (o *TextOutput) OutputTags(colors ...string)
- func (o *TextOutput) OutputWords(line string, colors ...string)
- func (o *TextOutput) Print(msg ...interface{})
- func (o *TextOutput) Printf(msg ...interface{})
- func (o *TextOutput) Println(msg ...interface{})
- func (o *TextOutput) Tags(colors ...string) string
- func (o *TextOutput) White(s string) string
- func (o *TextOutput) Words(line string, colors ...string) string
Constants ¶
This section is empty.
Variables ¶
var EnvNoColor = env.Bool("NO_COLOR")
Respect the NO_COLOR environment variable
Functions ¶
This section is empty.
Types ¶
type CharAttribute ¶ added in v1.8.0
type CharAttribute struct { A vt100.AttributeColor R rune }
CharAttribute is a rune and a color attribute
type TextOutput ¶
type TextOutput struct {
// contains filtered or unexported fields
}
TextOutput keeps state about verbosity and if colors are enabled
func New ¶
func New() *TextOutput
New creates a new TextOutput struct, which is enabled by default and with colors turned on. If the NO_COLOR environment variable is set, colors are disabled.
func NewTextOutput ¶ added in v1.2.0
func NewTextOutput(color, enabled bool) *TextOutput
NewTextOutput can initialize a new TextOutput struct, which can have colors turned on or off and where the output can be enabled (verbose) or disabled (silent). If NO_COLOR is set, colors are disabled, regardless.
func (*TextOutput) ColorOff ¶ added in v1.4.0
func (o *TextOutput) ColorOff() string
Change the color state in the terminal emulator
func (*TextOutput) ColorOn ¶ added in v1.4.0
func (o *TextOutput) ColorOn(attribute1, attribute2 int) string
Change the color state in the terminal emulator
func (*TextOutput) DarkBlue ¶
func (o *TextOutput) DarkBlue(s string) string
func (*TextOutput) DarkCyan ¶
func (o *TextOutput) DarkCyan(s string) string
func (*TextOutput) DarkGray ¶
func (o *TextOutput) DarkGray(s string) string
func (*TextOutput) DarkGreen ¶
func (o *TextOutput) DarkGreen(s string) string
func (*TextOutput) DarkPurple ¶
func (o *TextOutput) DarkPurple(s string) string
func (*TextOutput) DarkRed ¶
func (o *TextOutput) DarkRed(s string) string
func (*TextOutput) DarkTags ¶ added in v1.5.0
func (o *TextOutput) DarkTags(colors ...string) string
Replace <blue> with starting a light blue color attribute and <off> with using the default attributes. </blue> can also be used for using the default attributes.
func (*TextOutput) DarkYellow ¶
func (o *TextOutput) DarkYellow(s string) string
func (*TextOutput) Disable ¶ added in v1.5.0
func (o *TextOutput) Disable()
func (*TextOutput) DisableColors ¶ added in v1.5.0
func (o *TextOutput) DisableColors()
func (*TextOutput) Disabled ¶ added in v1.11.0
func (o *TextOutput) Disabled() bool
Disabled returns true if all output is disabled
func (*TextOutput) Enable ¶ added in v1.5.0
func (o *TextOutput) Enable()
func (*TextOutput) EnableColors ¶ added in v1.5.0
func (o *TextOutput) EnableColors()
func (*TextOutput) Enabled ¶ added in v1.11.0
func (o *TextOutput) Enabled() bool
Enabled returns true if any output is enabled
func (*TextOutput) Err ¶
func (o *TextOutput) Err(msg string)
Write an error message in red to stderr if output is enabled
func (*TextOutput) ErrExit ¶
func (o *TextOutput) ErrExit(msg string)
Write an error message to stderr and quit with exit code 1
func (*TextOutput) Extract ¶ added in v1.8.0
func (o *TextOutput) Extract(s string) []CharAttribute
Extract iterates over an ANSI encoded string, parsing out color codes and creating a slice of CharAttribute structures. Each CharAttribute in the slice represents a character in the input string and its corresponding color attributes. This function handles escaping sequences and converts ANSI color codes to vt100.AttributeColor structs.
func (*TextOutput) Fprint ¶ added in v1.12.7
func (o *TextOutput) Fprint(w io.Writer, msg ...interface{})
Write a message to the given io.Writer if output is enabled
func (*TextOutput) Fprintf ¶ added in v1.12.7
func (o *TextOutput) Fprintf(w io.Writer, msg ...interface{})
Write a message to the given io.Writer if output is enabled
func (*TextOutput) Fprintln ¶ added in v1.12.7
func (o *TextOutput) Fprintln(w io.Writer, msg ...interface{})
Write a message to the given io.Writer if output is enabled
func (*TextOutput) InterfaceTags ¶ added in v1.11.0
func (o *TextOutput) InterfaceTags(colors ...interface{}) string
InterfaceTags is the same as LightTags, but with interfaces
func (*TextOutput) LightBlue ¶
func (o *TextOutput) LightBlue(s string) string
func (*TextOutput) LightCyan ¶
func (o *TextOutput) LightCyan(s string) string
func (*TextOutput) LightGreen ¶
func (o *TextOutput) LightGreen(s string) string
func (*TextOutput) LightPurple ¶
func (o *TextOutput) LightPurple(s string) string
func (*TextOutput) LightRed ¶
func (o *TextOutput) LightRed(s string) string
func (*TextOutput) LightTags ¶ added in v1.5.0
func (o *TextOutput) LightTags(colors ...string) string
Replace <blue> with starting a light blue color attribute and <off> with using the default attributes. </blue> can also be used for using the default attributes.
func (*TextOutput) LightYellow ¶
func (o *TextOutput) LightYellow(s string) string
func (*TextOutput) OutputTags ¶ added in v1.7.0
func (o *TextOutput) OutputTags(colors ...string)
OutputTags will output text that may have tags like "<blue>", "</blue>" or "<off>" for enabling or disabling color attributes. Respects the color/enabled settings of this TextOutput.
func (*TextOutput) OutputWords ¶ added in v1.7.0
func (o *TextOutput) OutputWords(line string, colors ...string)
Given a line with words and several color strings, color the words in the order of the colors. The last color will color the rest of the words.
func (*TextOutput) Print ¶ added in v1.11.0
func (o *TextOutput) Print(msg ...interface{})
Write a message to stdout if output is enabled
func (*TextOutput) Printf ¶ added in v1.11.0
func (o *TextOutput) Printf(msg ...interface{})
Write a message to stdout if output is enabled
func (*TextOutput) Println ¶
func (o *TextOutput) Println(msg ...interface{})
Write a message to stdout if output is enabled
func (*TextOutput) Tags ¶ added in v1.5.0
func (o *TextOutput) Tags(colors ...string) string
Same as LightTags
func (*TextOutput) White ¶
func (o *TextOutput) White(s string) string