Documentation ¶
Index ¶
- Constants
- Variables
- func AltScreen()
- func ClearLine()
- func ClearLines(n int)
- func ClearScreen()
- func ConvertToRGB(c Color) colorful.Color
- func CursorNextLine(n int)
- func CursorPrevLine(n int)
- func ExitAltScreen()
- func HasDarkBackground() bool
- func HideCursor()
- func MoveCursor(row int, column int)
- func ShowCursor()
- func TemplateFuncs(p Profile) template.FuncMap
- type ANSI256Color
- type ANSIColor
- type Color
- type NoColor
- type Profile
- type RGBColor
- type Style
- func (t Style) Background(c Color) Style
- func (t Style) Blink() Style
- func (t Style) Bold() Style
- func (t Style) CrossOut() Style
- func (t Style) Faint() Style
- func (t Style) Foreground(c Color) Style
- func (t Style) Italic() Style
- func (t Style) Overline() Style
- func (t Style) Reverse() Style
- func (t Style) String() string
- func (t Style) Styled(s string) string
- func (t Style) Underline() Style
Constants ¶
const ( Foreground = "38" Background = "48" )
const ( AltScreenSeq = "?1049h" ExitAltScreenSeq = "?1049l" CursorUpSeq = "%dA" CursorDownSeq = "%dB" CursorForwardSeq = "%dC" CursorBackSeq = "%dD" CursorNextLineSeq = "%dE" CursorPreviousLineSeq = "%dF" CursorHorizontalSeq = "%dG" CursorPositionSeq = "%d;%dH" EraseDisplaySeq = "%dJ" EraseLineSeq = "%dK" ScrollUpSeq = "%dS" ScrollDownSeq = "%dT" ShowCursorSeq = "?25h" HideCursorSeq = "?25l" )
const ( ResetSeq = "0" BoldSeq = "1" FaintSeq = "2" ItalicSeq = "3" UnderlineSeq = "4" BlinkSeq = "5" ReverseSeq = "7" CrossOutSeq = "9" OverlineSeq = "53" )
const ( CSI = "\x1b[" Ascii = Profile(iota) ANSI ANSI256 TrueColor )
Variables ¶
var (
ErrInvalidColor = errors.New("invalid color")
)
var (
ErrStatusReport = errors.New("unable to retrieve status report")
)
var ForceColor bool = false
ForceColor overwrites the tty check, e.g. useful when generating shell prompts.
Functions ¶
func AltScreen ¶
func AltScreen()
AltScreen switches to the altscreen. The former view can be restored with ExitAltScreen().
func ConvertToRGB ¶
func ConvertToRGB(c Color) colorful.Color
func CursorNextLine ¶
func CursorNextLine(n int)
CursorNextLine moves the cursor down a given number of lines and places it at the beginning of the line.
func CursorPrevLine ¶
func CursorPrevLine(n int)
CursorPrevLine moves the cursor up a given number of lines and places it at the beginning of the line.
func ExitAltScreen ¶
func ExitAltScreen()
ExitAltScreen exits the altscreen and returns to the former terminal view.
func HasDarkBackground ¶
func HasDarkBackground() bool
HasDarkBackground returns whether terminal uses a dark-ish background
func MoveCursor ¶
MoveCursor moves the cursor to a given position.
func TemplateFuncs ¶
TemplateFuncs contains a few useful template helpers
Types ¶
type ANSI256Color ¶
type ANSI256Color int
ANSI256Color is a color (16-255) as defined by the ANSI Standard
func (ANSI256Color) Sequence ¶
func (c ANSI256Color) Sequence(bg bool) string
type Color ¶
func BackgroundColor ¶
func BackgroundColor() Color
BackgroundColor returns the terminal's default background color
func ForegroundColor ¶
func ForegroundColor() Color
ForegroundColor returns the terminal's default foreground color
type Profile ¶
type Profile int
func ColorProfile ¶
func ColorProfile() Profile
ColorProfile returns the supported color profile: Ascii, ANSI, ANSI256, or TrueColor
type Style ¶
type Style struct {
// contains filtered or unexported fields
}
Style is a string that various rendering styles can be applied to.
func (Style) Background ¶
Background sets a background color
func (Style) Foreground ¶
Foreground sets a foreground color