Skip to content

Commit

Permalink
add new colors
Browse files Browse the repository at this point in the history
  • Loading branch information
mkideal committed Aug 31, 2024
1 parent 93c90e9 commit d928653
Showing 1 changed file with 62 additions and 8 deletions.
70 changes: 62 additions & 8 deletions term/term.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,17 @@ func (w *colorizeWriter) Write(p []byte) (n int, err error) {
const Reset = "\033[0m"

const (
None = Color("-")
None = Color("-")
Bold = Color("\033[1m")
Dim = Color("\033[2m")
Italic = Color("\033[3m")
Underline = Color("\033[4m")
Blink = Color("\033[5m")
Reverse = Color("\033[7m")
Hidden = Color("\033[8m")

// Basic colors
Black = Color("\033[30m")
Red = Color("\033[31m")
Green = Color("\033[32m")
Yellow = Color("\033[33m")
Expand All @@ -82,6 +92,8 @@ const (
Cyan = Color("\033[36m")
White = Color("\033[37m")

// Bright colors
BrightBlack = Color("\033[90m")
BrightRed = Color("\033[91m")
BrightGreen = Color("\033[92m")
BrightYellow = Color("\033[93m")
Expand All @@ -90,15 +102,57 @@ const (
BrightCyan = Color("\033[96m")
BrightWhite = Color("\033[97m")

// 256 colors
Turquoise = Color("\033[38;5;80m")
Orange = Color("\033[38;5;214m")
Pink = Color("\033[38;5;200m")
Violet = Color("\033[38;5;135m")
LightGreen = Color("\033[38;5;119m")
LightBlue = Color("\033[38;5;123m")
// Background colors
BgBlack = Color("\033[40m")
BgRed = Color("\033[41m")
BgGreen = Color("\033[42m")
BgYellow = Color("\033[43m")
BgBlue = Color("\033[44m")
BgMagenta = Color("\033[45m")
BgCyan = Color("\033[46m")
BgWhite = Color("\033[47m")

// Bright background colors
BgBrightBlack = Color("\033[100m")
BgBrightRed = Color("\033[101m")
BgBrightGreen = Color("\033[102m")
BgBrightYellow = Color("\033[103m")
BgBrightBlue = Color("\033[104m")
BgBrightMagenta = Color("\033[105m")
BgBrightCyan = Color("\033[106m")
BgBrightWhite = Color("\033[107m")

// 256-color mode
Turquoise = Color("\033[38;5;80m")
Orange = Color("\033[38;5;214m")
Pink = Color("\033[38;5;200m")
Violet = Color("\033[38;5;135m")
LightGreen = Color("\033[38;5;119m")
LightBlue = Color("\033[38;5;123m")
DeepPink = Color("\033[38;5;198m")
LightSeaGreen = Color("\033[38;5;37m")
MediumPurple = Color("\033[38;5;141m")
DarkOrange = Color("\033[38;5;208m")
SteelBlue = Color("\033[38;5;67m")
IndianRed = Color("\033[38;5;167m")
Chartreuse = Color("\033[38;5;118m")
MediumOrchid = Color("\033[38;5;134m")
DodgerBlue = Color("\033[38;5;33m")
Crimson = Color("\033[38;5;160m")
MediumSeaGreen = Color("\033[38;5;48m")
Gold = Color("\033[38;5;220m")
)

// RGB color function
func RGB(r, g, b int) Color {
return Color(fmt.Sprintf("\033[38;2;%d;%d;%dm", r, g, b))
}

// Background RGB color function
func BgRGB(r, g, b int) Color {
return Color(fmt.Sprintf("\033[48;2;%d;%d;%dm", r, g, b))
}

// Color represents a terminal color.
type Color string

Expand Down

0 comments on commit d928653

Please sign in to comment.