Documentation
¶
Overview ¶
Package ansi allows for advanced terminal text manipulation.
Index ¶
- Variables
- func Confirm(message string) bool
- func Fprint(output io.Writer, col AnsiColor, s ...any)
- func Fprintf(output io.Writer, col AnsiColor, s string, args ...any)
- func Fprintln(output io.Writer, col AnsiColor, s ...any)
- func IsBold() bool
- func IsReversed() bool
- func IsUnderline() bool
- func Print(col AnsiColor, s ...any)
- func Printf(col AnsiColor, s string, args ...any)
- func Println(col AnsiColor, s ...any)
- func Prompt(message string) string
- func PromptPassword(message string) string
- func PromptWithDefault(message, defaultValue string) string
- func ResetAll()
- func SetAll(fg, bg AnsiColor, bold, underline, reversed bool)
- func SetBg(bg AnsiColor)
- func SetBold(bold bool)
- func SetFg(fg AnsiColor)
- func SetReversed(reversed bool)
- func SetUnderline(underline bool)
- type AnsiColor
- type Table
Constants ¶
This section is empty.
Variables ¶
var ( Black = AnsiColor{false, 30} BoldBlack = AnsiColor{true, 30} Red = AnsiColor{false, 31} BoldRed = AnsiColor{true, 31} Green = AnsiColor{false, 32} BoldGreen = AnsiColor{true, 32} Yellow = AnsiColor{false, 33} BoldYellow = AnsiColor{true, 33} Blue = AnsiColor{false, 34} BoldBlue = AnsiColor{true, 34} Purple = AnsiColor{false, 35} BoldPurple = AnsiColor{true, 35} Cyan = AnsiColor{false, 36} BoldCyan = AnsiColor{true, 36} White = AnsiColor{false, 37} BoldWhite = AnsiColor{true, 37} Default = AnsiColor{false, 39} Bold = AnsiColor{false, 1} NotBold = AnsiColor{false, 22} Underline = AnsiColor{false, 4} NotUnderline = AnsiColor{false, 24} Reversed = AnsiColor{false, 7} NotReversed = AnsiColor{false, 27} )
Functions ¶
func Fprint ¶
Fprint is a replacement for fmt.Fprint, which accepts an AnsiColor as the first argument.
func Fprintf ¶
Fprintf is a replacement for fmt.Fprintf, which accepts an AnsiColor as the first argument.
func Fprintln ¶
Fprintln is a replacement for fmt.Fprintln, which accepts an AnsiColor as the first argument.
func IsReversed ¶
func IsReversed() bool
func IsUnderline ¶
func IsUnderline() bool
func Print ¶
Print is a replacement for fmt.Print, which accepts an AnsiColor as the first argument.
func Printf ¶
Printf is a replacement for fmt.Printf, which accepts an AnsiColor as the first argument.
func Println ¶
Println is a replacement for fmt.Println, which accepts an AnsiColor as the first argument.
func PromptPassword ¶
PromptPassword securely asks for a hidden input (e.g. password).
func PromptWithDefault ¶
PromptWithDefault returns the user input or a default if Enter is pressed.
func SetAll ¶
SetAll sets the foreground, background, bold, underline and reversed properties at once.
func SetUnderline ¶
func SetUnderline(underline bool)
SetUnderline sets the text to be underlined or not.
Types ¶
type AnsiColor ¶
type AnsiColor struct {
// contains filtered or unexported fields
}
func GetBgColor ¶
func GetBgColor() AnsiColor
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
Table represents a simple text-based table.
func (*Table) SetPadding ¶
SetPadding allows customizing the spacing between columns.