|
1 | 1 | package color |
2 | 2 |
|
3 | 3 | var ( |
4 | | - Reset = "\033[0m" |
5 | | - Bold = "\033[1m" |
6 | | - Red = "\033[31m" |
7 | | - Green = "\033[32m" |
8 | | - Yellow = "\033[33m" |
9 | | - Blue = "\033[34m" |
10 | | - Purple = "\033[35m" |
11 | | - Cyan = "\033[36m" |
12 | | - Gray = "\033[37m" |
13 | | - White = "\033[97m" |
| 4 | + Reset = "\033[0m" |
| 5 | + Bold = "\033[1m" |
| 6 | + Underline = "\033[4m" |
| 7 | + Black = "\033[30m" |
| 8 | + Red = "\033[31m" |
| 9 | + Green = "\033[32m" |
| 10 | + Yellow = "\033[33m" |
| 11 | + Blue = "\033[34m" |
| 12 | + Purple = "\033[35m" |
| 13 | + Cyan = "\033[36m" |
| 14 | + Gray = "\033[37m" |
| 15 | + White = "\033[97m" |
14 | 16 | ) |
15 | 17 |
|
16 | 18 | // Ize is an alias for the Colorize function |
17 | 19 | // |
18 | 20 | // Example: |
19 | | -// println(color.Ize(color.Red, "This is red")) |
| 21 | +// |
| 22 | +// println(color.Ize(color.Red, "This is red")) |
20 | 23 | func Ize(color, s string) string { |
21 | 24 | return Colorize(color, s) |
22 | 25 | } |
23 | 26 |
|
24 | 27 | // Colorize wraps a given message in a given color. |
25 | 28 | // |
26 | 29 | // Example: |
27 | | -// println(color.Colorize(color.Red, "This is red")) |
| 30 | +// |
| 31 | +// println(color.Colorize(color.Red, "This is red")) |
28 | 32 | func Colorize(color, s string) string { |
29 | 33 | return color + s + Reset |
30 | 34 | } |
31 | 35 |
|
32 | 36 | // InBold wraps the given string s in Bold |
33 | 37 | // |
34 | 38 | // Example: |
35 | | -// println(color.InBold("This is bold")) |
| 39 | +// |
| 40 | +// println(color.InBold("This is bold")) |
36 | 41 | func InBold(s string) string { |
37 | 42 | return Colorize(Bold, s) |
38 | 43 | } |
39 | 44 |
|
| 45 | +// InUnderline wraps the given string s in Underline |
| 46 | +// |
| 47 | +// Example: |
| 48 | +// |
| 49 | +// println(color.InUnderline("This is underlined")) |
| 50 | +func InUnderline(s string) string { |
| 51 | + return Colorize(Underline, s) |
| 52 | +} |
| 53 | + |
| 54 | +// InBlack wraps the given string s in Black |
| 55 | +// |
| 56 | +// Example: |
| 57 | +// |
| 58 | +// println(color.InBlack("This is black")) |
| 59 | +func InBlack(s string) string { |
| 60 | + return Colorize(Black, s) |
| 61 | +} |
| 62 | + |
40 | 63 | // InRed wraps the given string s in Red |
41 | 64 | // |
42 | 65 | // Example: |
43 | | -// println(color.InRed("This is red")) |
| 66 | +// |
| 67 | +// println(color.InRed("This is red")) |
44 | 68 | func InRed(s string) string { |
45 | 69 | return Colorize(Red, s) |
46 | 70 | } |
47 | 71 |
|
48 | 72 | // InGreen wraps the given string s in Green |
49 | 73 | // |
50 | 74 | // Example: |
51 | | -// println(color.InGreen("This is green")) |
| 75 | +// |
| 76 | +// println(color.InGreen("This is green")) |
52 | 77 | func InGreen(s string) string { |
53 | 78 | return Colorize(Green, s) |
54 | 79 | } |
55 | 80 |
|
56 | 81 | // InYellow wraps the given string s in Yellow |
57 | 82 | // |
58 | 83 | // Example: |
59 | | -// println(color.InYellow("This is yellow")) |
| 84 | +// |
| 85 | +// println(color.InYellow("This is yellow")) |
60 | 86 | func InYellow(s string) string { |
61 | 87 | return Colorize(Yellow, s) |
62 | 88 | } |
63 | 89 |
|
64 | 90 | // InBlue wraps the given string s in Blue |
65 | 91 | // |
66 | 92 | // Example: |
67 | | -// println(color.InBlue("This is blue")) |
| 93 | +// |
| 94 | +// println(color.InBlue("This is blue")) |
68 | 95 | func InBlue(s string) string { |
69 | 96 | return Colorize(Blue, s) |
70 | 97 | } |
71 | 98 |
|
72 | 99 | // InPurple wraps the given string s in Purple |
73 | 100 | // |
74 | 101 | // Example: |
75 | | -// println(color.InPurple("This is purple")) |
| 102 | +// |
| 103 | +// println(color.InPurple("This is purple")) |
76 | 104 | func InPurple(s string) string { |
77 | 105 | return Colorize(Purple, s) |
78 | 106 | } |
79 | 107 |
|
80 | 108 | // InCyan wraps the given string s in Cyan |
81 | 109 | // |
82 | 110 | // Example: |
83 | | -// println(color.InCyan("This is cyan")) |
| 111 | +// |
| 112 | +// println(color.InCyan("This is cyan")) |
84 | 113 | func InCyan(s string) string { |
85 | 114 | return Colorize(Cyan, s) |
86 | 115 | } |
87 | 116 |
|
88 | 117 | // InGray wraps the given string s in Gray |
89 | 118 | // |
90 | 119 | // Example: |
91 | | -// println(color.InGray("This is gray")) |
| 120 | +// |
| 121 | +// println(color.InGray("This is gray")) |
92 | 122 | func InGray(s string) string { |
93 | 123 | return Colorize(Gray, s) |
94 | 124 | } |
95 | 125 |
|
96 | 126 | // InWhite wraps the given string s in White |
97 | 127 | // |
98 | 128 | // Example: |
99 | | -// println(color.InWhite("This is white")) |
| 129 | +// |
| 130 | +// println(color.InWhite("This is white")) |
100 | 131 | func InWhite(s string) string { |
101 | 132 | return Colorize(White, s) |
102 | 133 | } |
0 commit comments