diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2023-05-21 10:45:45 +1000 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2023-05-21 10:46:13 +1000 |
commit | 820f7b94044bbd46f0c34c0e563058e1e785c27b (patch) | |
tree | 288de6759e2f712f3fbc4a6bf08511d2322e8a96 /pkg | |
parent | 2e0d0a92eedef1c9059e666548004e03aa143c8a (diff) |
Support strikethrough text style
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/gui/style/decoration.go | 19 | ||||
-rw-r--r-- | pkg/gui/style/text_style.go | 6 | ||||
-rw-r--r-- | pkg/theme/style.go | 2 |
3 files changed, 24 insertions, 3 deletions
diff --git a/pkg/gui/style/decoration.go b/pkg/gui/style/decoration.go index f6fedb879..b5d95b645 100644 --- a/pkg/gui/style/decoration.go +++ b/pkg/gui/style/decoration.go @@ -3,9 +3,10 @@ package style import "github.com/gookit/color" type Decoration struct { - bold bool - underline bool - reverse bool + bold bool + underline bool + reverse bool + strikethrough bool } func (d *Decoration) SetBold() { @@ -20,6 +21,10 @@ func (d *Decoration) SetReverse() { d.reverse = true } +func (d *Decoration) SetStrikethrough() { + d.strikethrough = true +} + func (d Decoration) ToOpts() color.Opts { opts := make([]color.Color, 0, 3) @@ -35,6 +40,10 @@ func (d Decoration) ToOpts() color.Opts { opts = append(opts, color.OpReverse) } + if d.strikethrough { + opts = append(opts, color.OpStrikethrough) + } + return opts } @@ -51,5 +60,9 @@ func (d Decoration) Merge(other Decoration) Decoration { d.reverse = true } + if other.strikethrough { + d.strikethrough = true + } + return d } diff --git a/pkg/gui/style/text_style.go b/pkg/gui/style/text_style.go index 96d43a8f0..3eee68eff 100644 --- a/pkg/gui/style/text_style.go +++ b/pkg/gui/style/text_style.go @@ -98,6 +98,12 @@ func (b TextStyle) SetReverse() TextStyle { return b } +func (b TextStyle) SetStrikethrough() TextStyle { + b.decoration.SetStrikethrough() + b.Style = b.deriveStyle() + return b +} + func (b TextStyle) SetBg(color Color) TextStyle { b.bg = &color b.Style = b.deriveStyle() diff --git a/pkg/theme/style.go b/pkg/theme/style.go index f090068e0..43e81315d 100644 --- a/pkg/theme/style.go +++ b/pkg/theme/style.go @@ -17,6 +17,8 @@ func GetTextStyle(keys []string, background bool) style.TextStyle { s = s.SetReverse() case "underline": s = s.SetUnderline() + case "strikethrough": + s = s.SetStrikethrough() default: value, present := style.ColorMap[key] if present { |