...

Package ansi

import "simonwaldherr.de/go/golibs/ansi"
Overview
Index

Overview ▾

Package ansi can print colored and styled text to your terminal.

Constants

defines supported colors

const (
    Black = Col(iota)
    Red
    Green
    Yellow
    Blue
    Magenta
    Cyan
    White
)

defines text styling options

const (
    TReset = Col(iota)
    TBold
    TFaint
    TItalic
    TUnderline
    TBlinkSlow
    TBlinkFast
    TNegative
    TConceal
    TCrossedOut
)

Foreground text colors

const (
    FgBlack = Col(iota + 30)
    FgRed
    FgGreen
    FgYellow
    FgBlue
    FgMagenta
    FgCyan
    FgWhite
)

Background text colors

const (
    BgBlack = Col(iota + 40)
    BgRed
    BgGreen
    BgYellow
    BgBlue
    BgMagenta
    BgCyan
    BgWhite
)

func BgColor

func BgColor(str interface{}, col Col) string

BgColor adds the color code of col as background color to str and returns as string

func Bold

func Bold(str interface{}) string

Bold surrounds str with the code for bold styled text

func Color

func Color(str interface{}, col Col) string

Color adds the color code of col as text color to str and returns as string

func Log

func Log(valuea ...interface{}) interface{}

Log prints red text via log package

func Set

func Set(str interface{}, Attribute ...Col) string

Set sets styling options on strings and stringable interfaces

func Underline

func Underline(str interface{}) string

Underline surrounds str with the code for underlined text

type Col

Col defines supported colors

type Col int