Documentation
¶
Overview ¶
Package ansi allows for advanced terminal text manipulation.
Package ansi allows for advanced terminal text manipulation.
Index ¶
- Variables
- func Backspace(n int)
- func CarriageReturn()
- func ClearLine()
- func ClearScreen()
- func ClearToEnd()
- 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 GetPos() (int, int)
- func HideCursor()
- func MoveDown(n int)
- func MoveLeft(n int)
- func MoveRight(n int)
- func MoveTo(x, y int)
- func MoveUp(n int)
- func NewLine()
- func Print(col AnsiColor, s ...any)
- func Printf(col AnsiColor, s string, args ...any)
- func Println(col AnsiColor, s ...any)
- func ResetAll()
- func ResetScrollRegion()
- func Restore()
- func Save()
- 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 SetScrollRegion(start, end int)
- func SetUnderline(underline bool)
- func ShowCursor()
- func Tab()
- func TermSize() (int, int)
- type AnsiColor
Constants ¶
This section is empty.
Variables ¶
var ( // Black sets the ansi color black. Black = AnsiColor{false, 30} // BoldBlack sets the ansi color black and bold. BoldBlack = AnsiColor{true, 30} // Red sets the ansi color red. Red = AnsiColor{false, 31} // BoldRed sets the ansi color red and bold. BoldRed = AnsiColor{true, 31} // Green sets the ansi color green. Green = AnsiColor{false, 32} // BoldGreen sets the ansi color green and bold. BoldGreen = AnsiColor{true, 32} // Yellow sets the ansi color yellow. Yellow = AnsiColor{false, 33} // BoldYellow sets the ansi color yellow and bold. BoldYellow = AnsiColor{true, 33} // Blue sets the ansi color blue. Blue = AnsiColor{false, 34} // BoldBlue sets the ansi color blue and bold. BoldBlue = AnsiColor{true, 34} // Purple sets the ansi color purple. Purple = AnsiColor{false, 35} // BoldPurple sets the ansi color purple and bold. BoldPurple = AnsiColor{true, 35} // Cyan sets the ansi color cyan. Cyan = AnsiColor{false, 36} // BoldCyan sets the ansi color cyan and bold. BoldCyan = AnsiColor{true, 36} // White sets the ansi color white. White = AnsiColor{false, 37} // BoldWhite sets the ansi color white and bold. BoldWhite = AnsiColor{true, 37} // Default sets the ansi color to the default color. Default = AnsiColor{false, 39} // Bold sets the text to be bold. Bold = AnsiColor{false, 1} // NotBold sets the text to be not bold. NotBold = AnsiColor{false, 22} // Underline sets the text to be underlined. Underline = AnsiColor{false, 4} // NotUnderline sets the text to be not underlined. NotUnderline = AnsiColor{false, 24} // Reversed sets the text to be reversed. Reversed = AnsiColor{false, 7} // NotReversed sets the text to be not reversed. 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 MoveLeft ¶
func MoveLeft(n int)
MoveLeft moves the cursor to the left the specified number of spaces.
func MoveRight ¶
func MoveRight(n int)
MoveRight moves the cursor to the right the specified number of spaces.
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 SetAll ¶
SetAll sets the foreground, background, bold, underline and reversed properties at once.
func SetScrollRegion ¶
func SetScrollRegion(start, end int)
SetScrollRegion sets the start and end lines that the screen will scroll within.
func SetUnderline ¶
func SetUnderline(underline bool)
SetUnderline sets the text to be underlined or not.