55 "strconv"
66)
77
8- // ANSI escape sequences for text formatting
8+ // ANSI escape sequences for text formatting.
99const (
1010 // Text formatting
1111 AnsiReset = "\x1b [0m"
@@ -58,7 +58,7 @@ const (
5858 AnsiBgBrightWhite = "\x1b [107m"
5959)
6060
61- // HeaderStyle defines the styling for table headers
61+ // HeaderStyle defines the styling for table headers.
6262type HeaderStyle struct {
6363 // Text formatting
6464 Bold bool
@@ -78,37 +78,37 @@ type HeaderStyle struct {
7878 CustomSuffix string // Custom ANSI sequence to append
7979}
8080
81- // DefaultHeaderStyle returns a default header style with bold and underline
81+ // DefaultHeaderStyle returns a default header style with bold and underline.
8282func DefaultHeaderStyle () HeaderStyle {
8383 return HeaderStyle {
8484 Bold : true ,
8585 Underline : true ,
8686 }
8787}
8888
89- // BoldHeaderStyle returns a header style with bold text
89+ // BoldHeaderStyle returns a header style with bold text.
9090func BoldHeaderStyle () HeaderStyle {
9191 return HeaderStyle {
9292 Bold : true ,
9393 }
9494}
9595
96- // UnderlineHeaderStyle returns a header style with underlined text
96+ // UnderlineHeaderStyle returns a header style with underlined text.
9797func UnderlineHeaderStyle () HeaderStyle {
9898 return HeaderStyle {
9999 Underline : true ,
100100 }
101101}
102102
103- // ColoredHeaderStyle returns a header style with specified colors
103+ // ColoredHeaderStyle returns a header style with specified colors.
104104func ColoredHeaderStyle (fgColor , bgColor string ) HeaderStyle {
105105 return HeaderStyle {
106106 ForegroundColor : fgColor ,
107107 BackgroundColor : bgColor ,
108108 }
109109}
110110
111- // ApplyStyle applies the header style to the given text
111+ // ApplyStyle applies the header style to the given text.
112112func (hs HeaderStyle ) ApplyStyle (text string ) string {
113113 if hs .isEmpty () {
114114 return text
@@ -163,7 +163,7 @@ func (hs HeaderStyle) ApplyStyle(text string) string {
163163 return prefix + text + suffix
164164}
165165
166- // getPrefix returns the ANSI prefix for the header style
166+ // getPrefix returns the ANSI prefix for the header style.
167167func (hs HeaderStyle ) getPrefix () string {
168168 if hs .isEmpty () {
169169 return ""
@@ -212,7 +212,7 @@ func (hs HeaderStyle) getPrefix() string {
212212 return prefix
213213}
214214
215- // getSuffix returns the ANSI suffix for the header style
215+ // getSuffix returns the ANSI suffix for the header style.
216216func (hs HeaderStyle ) getSuffix () string {
217217 if hs .isEmpty () {
218218 return ""
@@ -228,15 +228,15 @@ func (hs HeaderStyle) getSuffix() string {
228228 return suffix
229229}
230230
231- // isEmpty checks if the header style has any formatting applied
231+ // isEmpty checks if the header style has any formatting applied.
232232func (hs HeaderStyle ) isEmpty () bool {
233233 return ! hs .Bold && ! hs .Underline && ! hs .Italic && ! hs .Dim &&
234234 ! hs .Blink && ! hs .Reverse && ! hs .Strike &&
235235 hs .ForegroundColor == "" && hs .BackgroundColor == "" &&
236236 hs .CustomPrefix == "" && hs .CustomSuffix == ""
237237}
238238
239- // Combine combines this header style with another, with the other style taking precedence
239+ // Combine combines this header style with another, with the other style taking precedence.
240240func (hs HeaderStyle ) Combine (other HeaderStyle ) HeaderStyle {
241241 result := hs
242242
@@ -282,22 +282,22 @@ func (hs HeaderStyle) Combine(other HeaderStyle) HeaderStyle {
282282 return result
283283}
284284
285- // RGB256 returns a 256-color ANSI code for foreground
285+ // RGB256 returns a 256-color ANSI code for foreground.
286286func RGB256 (colorCode int ) string {
287287 return "\x1b [38;5;" + strconv .Itoa (colorCode ) + "m"
288288}
289289
290- // BgRGB256 returns a 256-color ANSI code for background
290+ // BgRGB256 returns a 256-color ANSI code for background.
291291func BgRGB256 (colorCode int ) string {
292292 return "\x1b [48;5;" + strconv .Itoa (colorCode ) + "m"
293293}
294294
295- // TrueColorFg returns a true color (24-bit) ANSI code for foreground
295+ // TrueColorFg returns a true color (24-bit) ANSI code for foreground.
296296func TrueColorFg (r , g , b int ) string {
297297 return fmt .Sprintf ("\x1b [38;2;%d;%d;%dm" , r , g , b )
298298}
299299
300- // TrueColorBg returns a true color (24-bit) ANSI code for background
300+ // TrueColorBg returns a true color (24-bit) ANSI code for background.
301301func TrueColorBg (r , g , b int ) string {
302302 return fmt .Sprintf ("\x1b [48;2;%d;%d;%dm" , r , g , b )
303303}
0 commit comments