Skip to content

Commit

Permalink
Initial release
Browse files Browse the repository at this point in the history
  • Loading branch information
d048927 committed Dec 20, 2023
1 parent 3c2feb1 commit db3bca6
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea/
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,17 @@
# color
Go package containing color constants for ANSI terminals
Go package containing color constants for ANSI terminals.

# Intention
The idea is to provide constants that can be used for simple color commands. Colors are simple
string constants that can be included in printf commands, such as:
```go
fmt.Printf("Normal text – %sthis is green%s this is bold and green%s and this is regular again.\n",
color.Green, color.Bold, color.Reset)
```
You can also combine instructions such as:
```go
const ErrorColor = color.Red + color.Bold
fmt.Printf("%sThis is wrong\n%s", ErrorColor, color.Reset)
```
There is intentionally no code such as functions to print something in a specific color. If you are looking for
something like that, look into [fatih/color](https://github.com/fatih/color).
51 changes: 51 additions & 0 deletions constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package color

const (
Reset = "\033[0m"

Black = "\033[30m"
Red = "\033[31m"
Green = "\033[32m"
Yellow = "\033[33m"
Blue = "\033[34m"
Magenta = "\033[35m"
Cyan = "\033[36m"
White = "\033[37m"

HiBlack = "\033[90m"
HiRed = "\033[91m"
HiGreen = "\033[92m"
HiYellow = "\033[93m"
HiBlue = "\033[94m"
HiMagenta = "\033[95m"
HiCyan = "\033[96m"
HiWhite = "\033[97m"

Bold = "\033[1m"
Faint = "\033[2m"
Italic = "\033[3m"
Underline = "\033[4m"
BlinkSlow = "\033[5m"
BlinkRapid = "\033[6m"
ReverseVideo = "\033[7m"
Concealed = "\033[8m"
CrossedOut = "\033[9m"

BgBlack = "\033[40m"
BgRed = "\033[41m"
BgGreen = "\033[42m"
BgYellow = "\033[43m"
BgBlue = "\033[44m"
BgMagenta = "\033[45m"
BgCyan = "\033[46m"
BgWhite = "\033[47m"

BgHiBlack = "\033[100m"
BgHiRed = "\033[101m"
BgHiGreen = "\033[102m"
BgHiYellow = "\033[103m"
BgHiBlue = "\033[104m"
BgHiMagenta = "\033[105m"
BgHiCyan = "\033[106m"
BgHiWhite = "\033[107m"
)

0 comments on commit db3bca6

Please sign in to comment.