color256

package module
v0.0.0-...-129d0bf Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 1, 2021 License: MIT Imports: 4 Imported by: 21

README

color256

Simple way to spice up your terminal output.

Usage

  • Consult formats.go, bgColors.go, colors.go for all available functions.
  • Consult color256_test.go for examples.

BTW: color256_test.go is no proper unit test, but just a few examples to see if all works like I want.

Generate helper functions

genHelperGo.py is a simple python script which generates a ton of format helpers.

Credits:

Huge parts are highly inspierd by those packages and projects.

https://github.com/esimov/diagram/blob/master/color/color.go

https://github.com/fatih/color

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Bright   = Bold
	Colour   = Color
	BgColour = BgColor
)

Aliases

Functions

func BgBlack

func BgBlack(format string, a ...interface{}) string

BgBlack is a convenient to get a black string.

func BgBlue

func BgBlue(format string, a ...interface{}) string

BgBlue is a convenient to get a blue string.

func BgColor

func BgColor(c Colr, str string) string

BgColor returns a backgroundcolor escape string.

func BgCyan

func BgCyan(format string, a ...interface{}) string

BgCyan is a convenient to get a cyan string.

func BgGreen

func BgGreen(format string, a ...interface{}) string

BgGreen is a convenient to get a green string.

func BgHiBlack

func BgHiBlack(format string, a ...interface{}) string

BgHiBlack is a convenient to get a hiblack string.

func BgHiBlue

func BgHiBlue(format string, a ...interface{}) string

BgHiBlue is a convenient to get a hiblue string.

func BgHiCyan

func BgHiCyan(format string, a ...interface{}) string

BgHiCyan is a convenient to get a hicyan string.

func BgHiGreen

func BgHiGreen(format string, a ...interface{}) string

BgHiGreen is a convenient to get a higreen string.

func BgHiMagenta

func BgHiMagenta(format string, a ...interface{}) string

BgHiMagenta is a convenient to get a himagenta string.

func BgHiOrange

func BgHiOrange(format string, a ...interface{}) string

BgHiOrange is a convenient to get a hiorange string.

func BgHiPink

func BgHiPink(format string, a ...interface{}) string

BgHiPink is a convenient to get a hipink string.

func BgHiRed

func BgHiRed(format string, a ...interface{}) string

BgHiRed is a convenient to get a hired string.

func BgHiWhite

func BgHiWhite(format string, a ...interface{}) string

BgHiWhite is a convenient to get a hiwhite string.

func BgHiYellow

func BgHiYellow(format string, a ...interface{}) string

BgHiYellow is a convenient to get a hiyellow string.

func BgMagenta

func BgMagenta(format string, a ...interface{}) string

BgMagenta is a convenient to get a magenta string.

func BgOrange

func BgOrange(format string, a ...interface{}) string

BgOrange is a convenient to get a orange string.

func BgPink

func BgPink(format string, a ...interface{}) string

BgPink is a convenient to get a pink string.

func BgRed

func BgRed(format string, a ...interface{}) string

BgRed is a convenient to get a red string.

func BgWhite

func BgWhite(format string, a ...interface{}) string

BgWhite is a convenient to get a white string.

func BgYellow

func BgYellow(format string, a ...interface{}) string

BgYellow is a convenient to get a yellow string.

func Black

func Black(format string, a ...interface{}) string

Black is a convenient to get a black string.

func Blue

func Blue(format string, a ...interface{}) string

Blue is a convenient to get a blue string.

func Bold

func Bold(format string, a ...interface{}) string

Bold returns a bold string.

func Color

func Color(c Colr, str string) string

Color returns a color escape string.

func Cyan

func Cyan(format string, a ...interface{}) string

Cyan is a convenient to get a cyan string.

func Faint

func Faint(format string, a ...interface{}) string

Faint returns a faint string.

func Format

func Format(f Formt, str string) string

Format returns a format escape string.

func Green

func Green(format string, a ...interface{}) string

Green is a convenient to get a green string.

func HiBlack

func HiBlack(format string, a ...interface{}) string

HiBlack is a convenient to get a hiblack string.

func HiBlue

func HiBlue(format string, a ...interface{}) string

HiBlue is a convenient to get a hiblue string.

func HiCyan

func HiCyan(format string, a ...interface{}) string

HiCyan is a convenient to get a hicyan string.

func HiGreen

func HiGreen(format string, a ...interface{}) string

HiGreen is a convenient to get a higreen string.

func HiMagenta

func HiMagenta(format string, a ...interface{}) string

HiMagenta is a convenient to get a himagenta string.

func HiOrange

func HiOrange(format string, a ...interface{}) string

HiOrange is a convenient to get a hiorange string.

func HiPink

func HiPink(format string, a ...interface{}) string

HiPink is a convenient to get a hipink string.

func HiRed

func HiRed(format string, a ...interface{}) string

HiRed is a convenient to get a hired string.

func HiWhite

func HiWhite(format string, a ...interface{}) string

HiWhite is a convenient to get a hiwhite string.

func HiYellow

func HiYellow(format string, a ...interface{}) string

HiYellow is a convenient to get a hiyellow string.

func Init

func Init()

Init random number generator (Quick and dirty Windows hack)

func Italic

func Italic(format string, a ...interface{}) string

Italic returns an italic string.

func List

func List()

List all the colors with its color code

func Magenta

func Magenta(format string, a ...interface{}) string

Magenta is a convenient to get a magenta string.

func Orange

func Orange(format string, a ...interface{}) string

Orange is a convenient to get a orange string.

func Pink

func Pink(format string, a ...interface{}) string

Pink is a convenient to get a pink string.

func PrintBgBlack

func PrintBgBlack(format string, a ...interface{})

PrintBgBlack is a convenient helper function to print a black text. A newline is appended to format by default.

func PrintBgBlue

func PrintBgBlue(format string, a ...interface{})

PrintBgBlue is a convenient helper function to print a blue text. A newline is appended to format by default.

func PrintBgCyan

func PrintBgCyan(format string, a ...interface{})

PrintBgCyan is a convenient helper function to print a cyan text. A newline is appended to format by default.

func PrintBgGreen

func PrintBgGreen(format string, a ...interface{})

PrintBgGreen is a convenient helper function to print a green text. A newline is appended to format by default.

func PrintBgHiBlack

func PrintBgHiBlack(format string, a ...interface{})

PrintBgHiBlack is a convenient helper function to print a hiblack text. A newline is appended to format by default.

func PrintBgHiBlue

func PrintBgHiBlue(format string, a ...interface{})

PrintBgHiBlue is a convenient helper function to print a hiblue text. A newline is appended to format by default.

func PrintBgHiCyan

func PrintBgHiCyan(format string, a ...interface{})

PrintBgHiCyan is a convenient helper function to print a hicyan text. A newline is appended to format by default.

func PrintBgHiGreen

func PrintBgHiGreen(format string, a ...interface{})

PrintBgHiGreen is a convenient helper function to print a higreen text. A newline is appended to format by default.

func PrintBgHiMagenta

func PrintBgHiMagenta(format string, a ...interface{})

PrintBgHiMagenta is a convenient helper function to print a himagenta text. A newline is appended to format by default.

func PrintBgHiOrange

func PrintBgHiOrange(format string, a ...interface{})

PrintBgHiOrange is a convenient helper function to print a hiorange text. A newline is appended to format by default.

func PrintBgHiPink

func PrintBgHiPink(format string, a ...interface{})

PrintBgHiPink is a convenient helper function to print a hipink text. A newline is appended to format by default.

func PrintBgHiRed

func PrintBgHiRed(format string, a ...interface{})

PrintBgHiRed is a convenient helper function to print a hired text. A newline is appended to format by default.

func PrintBgHiWhite

func PrintBgHiWhite(format string, a ...interface{})

PrintBgHiWhite is a convenient helper function to print a hiwhite text. A newline is appended to format by default.

func PrintBgHiYellow

func PrintBgHiYellow(format string, a ...interface{})

PrintBgHiYellow is a convenient helper function to print a hiyellow text. A newline is appended to format by default.

func PrintBgMagenta

func PrintBgMagenta(format string, a ...interface{})

PrintBgMagenta is a convenient helper function to print a magenta text. A newline is appended to format by default.

func PrintBgOrange

func PrintBgOrange(format string, a ...interface{})

PrintBgOrange is a convenient helper function to print a orange text. A newline is appended to format by default.

func PrintBgPink

func PrintBgPink(format string, a ...interface{})

PrintBgPink is a convenient helper function to print a pink text. A newline is appended to format by default.

func PrintBgRed

func PrintBgRed(format string, a ...interface{})

PrintBgRed is a convenient helper function to print a red text. A newline is appended to format by default.

func PrintBgWhite

func PrintBgWhite(format string, a ...interface{})

PrintBgWhite is a convenient helper function to print a white text. A newline is appended to format by default.

func PrintBgYellow

func PrintBgYellow(format string, a ...interface{})

PrintBgYellow is a convenient helper function to print a yellow text. A newline is appended to format by default.

func PrintBlack

func PrintBlack(format string, a ...interface{})

PrintBlack is a convenient helper function to print a black text. A newline is appended to format by default.

func PrintBlue

func PrintBlue(format string, a ...interface{})

PrintBlue is a convenient helper function to print a blue text. A newline is appended to format by default.

func PrintBold

func PrintBold(format string, a ...interface{})

PrintBold is a convenient helper function to print a bold text. A newline is appended to format by default.

func PrintBright

func PrintBright(format string, a ...interface{})

PrintBright is a convenient helper function to print a bright text. A newline is appended to format by default.

func PrintCyan

func PrintCyan(format string, a ...interface{})

PrintCyan is a convenient helper function to print a cyan text. A newline is appended to format by default.

func PrintFaint

func PrintFaint(format string, a ...interface{})

PrintFaint is a convenient helper function to print a faint text. A newline is appended to format by default.

func PrintGreen

func PrintGreen(format string, a ...interface{})

PrintGreen is a convenient helper function to print a green text. A newline is appended to format by default.

func PrintHiBlack

func PrintHiBlack(format string, a ...interface{})

PrintHiBlack is a convenient helper function to print a hiblack text. A newline is appended to format by default.

func PrintHiBlue

func PrintHiBlue(format string, a ...interface{})

PrintHiBlue is a convenient helper function to print a hiblue text. A newline is appended to format by default.

func PrintHiCyan

func PrintHiCyan(format string, a ...interface{})

PrintHiCyan is a convenient helper function to print a hicyan text. A newline is appended to format by default.

func PrintHiGreen

func PrintHiGreen(format string, a ...interface{})

PrintHiGreen is a convenient helper function to print a higreen text. A newline is appended to format by default.

func PrintHiMagenta

func PrintHiMagenta(format string, a ...interface{})

PrintHiMagenta is a convenient helper function to print a himagenta text. A newline is appended to format by default.

func PrintHiOrange

func PrintHiOrange(format string, a ...interface{})

PrintHiOrange is a convenient helper function to print a hiorange text. A newline is appended to format by default.

func PrintHiPink

func PrintHiPink(format string, a ...interface{})

PrintHiPink is a convenient helper function to print a hipink text. A newline is appended to format by default.

func PrintHiRed

func PrintHiRed(format string, a ...interface{})

PrintHiRed is a convenient helper function to print a hired text. A newline is appended to format by default.

func PrintHiWhite

func PrintHiWhite(format string, a ...interface{})

PrintHiWhite is a convenient helper function to print a hiwhite text. A newline is appended to format by default.

func PrintHiYellow

func PrintHiYellow(format string, a ...interface{})

PrintHiYellow is a convenient helper function to print a hiyellow text. A newline is appended to format by default.

func PrintItalic

func PrintItalic(format string, a ...interface{})

PrintItalic is a convenient helper function to print a italic text. A newline is appended to format by default.

func PrintMagenta

func PrintMagenta(format string, a ...interface{})

PrintMagenta is a convenient helper function to print a magenta text. A newline is appended to format by default.

func PrintOrange

func PrintOrange(format string, a ...interface{})

PrintOrange is a convenient helper function to print a orange text. A newline is appended to format by default.

func PrintPink

func PrintPink(format string, a ...interface{})

PrintPink is a convenient helper function to print a pink text. A newline is appended to format by default.

func PrintRandom

func PrintRandom(format string, a ...interface{})

PrintRandom is a convenient helper function to print with random foreground. A newline is appended to format by default.

func PrintRed

func PrintRed(format string, a ...interface{})

PrintRed is a convenient helper function to print a red text. A newline is appended to format by default.

func PrintReversed

func PrintReversed(format string, a ...interface{})

PrintReversed is a convenient helper function to print a reversed text. A newline is appended to format by default.

func PrintUnderlined

func PrintUnderlined(format string, a ...interface{})

PrintUnderlined is a convenient helper function to print a underlined text. A newline is appended to format by default.

func PrintWhite

func PrintWhite(format string, a ...interface{})

PrintWhite is a convenient helper function to print a white text. A newline is appended to format by default.

func PrintYellow

func PrintYellow(format string, a ...interface{})

PrintYellow is a convenient helper function to print a yellow text. A newline is appended to format by default.

func Random

func Random(format string, a ...interface{}) string

Random is a convenient helper function to print with black foreground. A newline is appended to format by default.

func RandomColor

func RandomColor(min, max int) int

RandomColor returns a random color number.

func Red

func Red(format string, a ...interface{}) string

Red is a convenient to get a red string.

func Reversed

func Reversed(format string, a ...interface{}) string

Reversed returns an inversed string.

func Underlined

func Underlined(format string, a ...interface{}) string

Underlined returns an underlined string.

func White

func White(format string, a ...interface{}) string

White is a convenient to get a white string.

func Yellow

func Yellow(format string, a ...interface{}) string

Yellow is a convenient to get a yellow string.

Types

type Colr

type Colr int

Colr ansi colors (own type for type checking)

const (
	X800000 Colr = 1
	X008000 Colr = 2
	X808000 Colr = 3
	X000080 Colr = 4
	X800080 Colr = 5
	X008080 Colr = 6
	Xc0c0c0 Colr = 7
	X000000 Colr = 16
	X00005f Colr = 17
	X000087 Colr = 18
	X0000af Colr = 19
	X0000d7 Colr = 20
	X0000ff Colr = 21
	X005f00 Colr = 22
	X005f5f Colr = 23
	X005f87 Colr = 24
	X005faf Colr = 25
	X005fd7 Colr = 26
	X005fff Colr = 27
	X008700 Colr = 28
	X00875f Colr = 29
	X008787 Colr = 30
	X0087af Colr = 31
	X0087d7 Colr = 32
	X0087ff Colr = 33
	X00af00 Colr = 34
	X00af5f Colr = 35
	X00af87 Colr = 36
	X00afaf Colr = 37
	X00afd7 Colr = 38
	X00afff Colr = 39
	X00d700 Colr = 40
	X00d75f Colr = 41
	X00d787 Colr = 42
	X00d7af Colr = 43
	X00d7d7 Colr = 44
	X00d7ff Colr = 45
	X00ff00 Colr = 46
	X00ff5f Colr = 47
	X00ff87 Colr = 48
	X00ffaf Colr = 49
	X00ffd7 Colr = 50
	X00ffff Colr = 51
	X5f0000 Colr = 52
	X5f005f Colr = 53
	X5f0087 Colr = 54
	X5f00af Colr = 55
	X5f00d7 Colr = 56
	X5f00ff Colr = 57
	X5f5f00 Colr = 58
	X5f5f5f Colr = 59
	X5f5f87 Colr = 60
	X5f5faf Colr = 61
	X5f5fd7 Colr = 62
	X5f5fff Colr = 63
	X5f8700 Colr = 64
	X5f875f Colr = 65
	X5f8787 Colr = 66
	X5f87af Colr = 67
	X5f87d7 Colr = 68
	X5f87ff Colr = 69
	X5faf00 Colr = 70
	X5faf5f Colr = 71
	X5faf87 Colr = 72
	X5fafaf Colr = 73
	X5fafd7 Colr = 74
	X5fafff Colr = 75
	X5fd700 Colr = 76
	X5fd75f Colr = 77
	X5fd787 Colr = 78
	X5fd7af Colr = 79
	X5fd7d7 Colr = 80
	X5fd7ff Colr = 81
	X5fff00 Colr = 82
	X5fff5f Colr = 83
	X5fff87 Colr = 84
	X5fffaf Colr = 85
	X5fffd7 Colr = 86
	X5fffff Colr = 87
	X870000 Colr = 88
	X87005f Colr = 89
	X870087 Colr = 90
	X8700af Colr = 91
	X8700d7 Colr = 92
	X8700ff Colr = 93
	X875f00 Colr = 94
	X875f5f Colr = 95
	X875f87 Colr = 96
	X875faf Colr = 97
	X875fd7 Colr = 98
	X875fff Colr = 99
	X878700 Colr = 100
	X87875f Colr = 101
	X878787 Colr = 102
	X8787af Colr = 103
	X8787d7 Colr = 104
	X8787ff Colr = 105
	X87af00 Colr = 106
	X87af5f Colr = 107
	X87af87 Colr = 108
	X87afaf Colr = 109
	X87afd7 Colr = 110
	X87afff Colr = 111
	X87d700 Colr = 112
	X87d75f Colr = 113
	X87d787 Colr = 114
	X87d7af Colr = 115
	X87d7d7 Colr = 116
	X87d7ff Colr = 117
	X87ff00 Colr = 118
	X87ff5f Colr = 119
	X87ff87 Colr = 120
	X87ffaf Colr = 121
	X87ffd7 Colr = 122
	X87ffff Colr = 123
	Xaf0000 Colr = 124
	Xaf005f Colr = 125
	Xaf0087 Colr = 126
	Xaf00af Colr = 127
	Xaf00d7 Colr = 128
	Xaf00ff Colr = 129
	Xaf5f00 Colr = 130
	Xaf5f5f Colr = 131
	Xaf5f87 Colr = 132
	Xaf5faf Colr = 133
	Xaf5fd7 Colr = 134
	Xaf5fff Colr = 135
	Xaf8700 Colr = 136
	Xaf875f Colr = 137
	Xaf8787 Colr = 138
	Xaf87af Colr = 139
	Xaf87d7 Colr = 140
	Xaf87ff Colr = 141
	Xafaf00 Colr = 142
	Xafaf5f Colr = 143
	Xafaf87 Colr = 144
	Xafafaf Colr = 145
	Xafafd7 Colr = 146
	Xafafff Colr = 147
	Xafd700 Colr = 148
	Xafd75f Colr = 149
	Xafd787 Colr = 150
	Xafd7af Colr = 151
	Xafd7d7 Colr = 152
	Xafd7ff Colr = 153
	Xafff00 Colr = 154
	Xafff5f Colr = 155
	Xafff87 Colr = 156
	Xafffaf Colr = 157
	Xafffd7 Colr = 158
	Xafffff Colr = 159
	Xd70000 Colr = 160
	Xd7005f Colr = 161
	Xd70087 Colr = 162
	Xd700af Colr = 163
	Xd700d7 Colr = 164
	Xd700ff Colr = 165
	Xd75f00 Colr = 166
	Xd75f5f Colr = 167
	Xd75f87 Colr = 168
	Xd75faf Colr = 169
	Xd75fd7 Colr = 170
	Xd75fff Colr = 171
	Xd78700 Colr = 172
	Xd7875f Colr = 173
	Xd78787 Colr = 174
	Xd787af Colr = 175
	Xd787d7 Colr = 176
	Xd787ff Colr = 177
	Xd7af00 Colr = 178
	Xd7af5f Colr = 179
	Xd7af87 Colr = 180
	Xd7afaf Colr = 181
	Xd7afd7 Colr = 182
	Xd7afff Colr = 183
	Xd7d700 Colr = 184
	Xd7d75f Colr = 185
	Xd7d787 Colr = 186
	Xd7d7af Colr = 187
	Xd7d7d7 Colr = 188
	Xd7d7ff Colr = 189
	Xd7ff00 Colr = 190
	Xd7ff5f Colr = 191
	Xd7ff87 Colr = 192
	Xd7ffaf Colr = 193
	Xd7ffd7 Colr = 194
	Xd7ffff Colr = 195
	Xff0000 Colr = 196
	Xff005f Colr = 197
	Xff0087 Colr = 198
	Xff00af Colr = 199
	Xff00d7 Colr = 200
	Xff00ff Colr = 201
	Xff5f00 Colr = 202
	Xff5f5f Colr = 203
	Xff5f87 Colr = 204
	Xff5faf Colr = 205
	Xff5fd7 Colr = 206
	Xff5fff Colr = 207
	Xff8700 Colr = 208
	Xff875f Colr = 209
	Xff8787 Colr = 210
	Xff87af Colr = 211
	Xff87d7 Colr = 212
	Xff87ff Colr = 213
	Xffaf00 Colr = 214
	Xffaf5f Colr = 215
	Xffaf87 Colr = 216
	Xffafaf Colr = 217
	Xffafd7 Colr = 218
	Xffafff Colr = 219
	Xffd700 Colr = 220
	Xffd75f Colr = 221
	Xffd787 Colr = 222
	Xffd7af Colr = 223
	Xffd7d7 Colr = 224
	Xffd7ff Colr = 225
	Xffff00 Colr = 226
	Xffff5f Colr = 227
	Xffff87 Colr = 228
	Xffffaf Colr = 229
	Xffffd7 Colr = 230
	Xffffff Colr = 231
	X080808 Colr = 232
	X121212 Colr = 233
	X1c1c1c Colr = 234
	X262626 Colr = 235
	X303030 Colr = 236
	X3a3a3a Colr = 237
	X444444 Colr = 238
	X4e4e4e Colr = 239
	X585858 Colr = 240
	X626262 Colr = 241
	X6c6c6c Colr = 242
	X767676 Colr = 243
	X808080 Colr = 244
	X8a8a8a Colr = 245
	X949494 Colr = 246
	X9e9e9e Colr = 247
	Xa8a8a8 Colr = 248
	Xb2b2b2 Colr = 249
	Xbcbcbc Colr = 250
	Xc6c6c6 Colr = 251
	Xd0d0d0 Colr = 252
	Xdadada Colr = 253
	Xe4e4e4 Colr = 254
	Xeeeeee Colr = 255
)

Ansi Colors

const (
	ColBlack Colr = iota
	ColRed
	ColGreen
	ColYellow
	ColBlue
	ColMagenta
	ColCyan
	ColWhite
	ColHiBlack
	ColHiRed
	ColHiGreen
	ColHiYellow
	ColHiBlue
	ColHiMagenta
	ColHiCyan
	ColHiWhite

	ColOrange   Colr = 208
	ColHiOrange Colr = 214
	ColPink     Colr = 198
	ColHiPink   Colr = 205
)

Colors

type Formt

type Formt int

Formt text format (own type for type checking)

const (
	FmtReset Formt = iota
	FmtBold
	FmtFaint
	FmtItalic
	FmtUnderlined
	FmtBlinkSlow
	FmtBlinkRapid
	FmtReversed
	FmtConcealed
	FmtCrossedOut

	FmtFraktur Formt = iota + 19
	FmtDoublyUnderlined

	FmtFramed Formt = iota + 50
	FmtEncircled
	FmtOverlined
)

Formats

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL