...

Package color

import "github.com/henvic/httpretty/internal/color"
Overview
Index

Overview ▾

Package color can be used to add color to your terminal using ANSI escape code (or sequences).

See https://en.wikipedia.org/wiki/ANSI_escape_code Copy modified from https://github.com/fatih/color Copyright 2013 Fatih Arslan

func Escape

func Escape(s string) string

Escape text for terminal.

func Format

func Format(s ...interface{}) string

Format text for terminal. You can pass an arbitrary number of Attribute or []Attribute followed by any other values, that can either be a string or something else (that is converted to string using fmt.Sprint).

func StripAttributes

func StripAttributes(s ...interface{}) (raw string)

StripAttributes from input arguments and return unformatted text.

type Attribute

Attribute defines a single SGR (Select Graphic Rendition) code.

type Attribute int

Base attributes

const (
    Reset Attribute = iota
    Bold
    Faint
    Italic
    Underline
    BlinkSlow
    BlinkRapid
    ReverseVideo
    Concealed
    CrossedOut
)

Foreground text colors

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

Foreground Hi-Intensity text colors

const (
    FgHiBlack Attribute = iota + 90
    FgHiRed
    FgHiGreen
    FgHiYellow
    FgHiBlue
    FgHiMagenta
    FgHiCyan
    FgHiWhite
)

Background text colors

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

Background Hi-Intensity text colors

const (
    BgHiBlack Attribute = iota + 100
    BgHiRed
    BgHiGreen
    BgHiYellow
    BgHiBlue
    BgHiMagenta
    BgHiCyan
    BgHiWhite
)