1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-01-04 03:48:07 +02:00

Support strikethrough text style

This commit is contained in:
Jesse Duffield 2023-05-21 10:45:45 +10:00
parent 2e0d0a92ee
commit 820f7b9404
4 changed files with 26 additions and 4 deletions

View File

@ -88,7 +88,7 @@ git:
# displays the whole git graph by default in the commits panel (equivalent to passing the `--all` argument to `git log`)
showWholeGraph: false
skipHookPrefix: WIP
# The main branches. We colour commits green if they belong to one of these branches,
# The main branches. We colour commits green if they belong to one of these branches,
# so that you can easily see which commits are unique to your branch (coloured in yellow)
mainBranches: [master, main]
autoFetch: true
@ -347,6 +347,7 @@ The available attributes are:
- default
- reverse # useful for high-contrast
- underline
- strikethrough
## Highlighting the selected line

View File

@ -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
}

View File

@ -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()

View File

@ -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 {