@@ -19,7 +19,6 @@ const (
1919 // Boolean props come first.
2020 boldKey propKey = 1 << iota
2121 italicKey
22- underlineKey
2322 strikethroughKey
2423 reverseKey
2524 blinkKey
@@ -29,8 +28,10 @@ const (
2928 colorWhitespaceKey
3029
3130 // Non-boolean props.
31+ underlineKey
3232 foregroundKey
3333 backgroundKey
34+ underlineColorKey
3435 widthKey
3536 heightKey
3637 alignHorizontalKey
@@ -96,6 +97,24 @@ func (p props) has(k propKey) bool {
9697 return p & props (k ) != 0
9798}
9899
100+ // Underline is the style of the underline.
101+ type Underline uint8
102+
103+ const (
104+ // NoUnderline is no underline.
105+ NoUnderline = Underline (ansi .NoUnderlineStyle )
106+ // SingleUnderline is a single underline. This is the default when underline is enabled.
107+ SingleUnderline = Underline (ansi .SingleUnderlineStyle )
108+ // DoubleUnderline is a double underline.
109+ DoubleUnderline = Underline (ansi .DoubleUnderlineStyle )
110+ // CurlyUnderline is a curly underline.
111+ CurlyUnderline = Underline (ansi .CurlyUnderlineStyle )
112+ // DottedUnderline is a dotted underline.
113+ DottedUnderline = Underline (ansi .DottedUnderlineStyle )
114+ // DashedUnderline is a dashed underline.
115+ DashedUnderline = Underline (ansi .DashedUnderlineStyle )
116+ )
117+
99118// NewStyle returns a new, empty Style. While it's syntactic sugar for the
100119// [Style]{} primitive, it's recommended to use this function for creating styles
101120// in case the underlying implementation changes.
@@ -114,6 +133,9 @@ type Style struct {
114133 // props that have values
115134 fgColor color.Color
116135 bgColor color.Color
136+ ulColor color.Color
137+
138+ ul Underline
117139
118140 width int
119141 height int
@@ -234,15 +256,16 @@ func (s Style) Render(strs ...string) string {
234256
235257 bold = s .getAsBool (boldKey , false )
236258 italic = s .getAsBool (italicKey , false )
237- underline = s .getAsBool (underlineKey , false )
238259 strikethrough = s .getAsBool (strikethroughKey , false )
239260 reverse = s .getAsBool (reverseKey , false )
240261 blink = s .getAsBool (blinkKey , false )
241262 faint = s .getAsBool (faintKey , false )
242263
243264 fg = s .getAsColor (foregroundKey )
244265 bg = s .getAsColor (backgroundKey )
266+ ul = s .getAsColor (underlineColorKey )
245267
268+ underline = s .ul != NoUnderline
246269 width = s .getAsInt (widthKey )
247270 height = s .getAsInt (heightKey )
248271 horizontalAlign = s .getAsPosition (alignHorizontalKey )
@@ -322,8 +345,18 @@ func (s Style) Render(strs ...string) string {
322345 }
323346 }
324347
348+ if ul != noColor {
349+ te = te .UnderlineColor (ul )
350+ if colorWhitespace {
351+ teWhitespace = teWhitespace .UnderlineColor (ul )
352+ }
353+ if useSpaceStyler {
354+ teSpace = teSpace .UnderlineColor (ul )
355+ }
356+ }
357+
325358 if underline {
326- te = te .Underline ( )
359+ te = te .UnderlineStyle ( ansi . UnderlineStyle ( s . ul ) )
327360 }
328361 if strikethrough {
329362 te = te .Strikethrough ()
0 commit comments