mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-10-05 21:46:49 -04:00
Let strikethrough work in the theme colors that gocui draws
Config.md lists strikethrough as a modifier for theme colors, but only GetTextStyle knows it. GetGocuiStyle turns an unknown name into white, and white OR-ed with a palette color is white. So if you set a border color to [red, strikethrough], you get a white border without strikethrough. The same goes for the parts of the selected line, options text and default text colors that gocui draws. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
679fe58e8e
commit
c236214c29
+13
-12
@@ -7,18 +7,19 @@ import (
|
||||
)
|
||||
|
||||
var gocuiColorMap = map[string]gocui.Attribute{
|
||||
"default": gocui.ColorDefault,
|
||||
"black": gocui.ColorBlack,
|
||||
"red": gocui.ColorRed,
|
||||
"green": gocui.ColorGreen,
|
||||
"yellow": gocui.ColorYellow,
|
||||
"blue": gocui.ColorBlue,
|
||||
"magenta": gocui.ColorMagenta,
|
||||
"cyan": gocui.ColorCyan,
|
||||
"white": gocui.ColorWhite,
|
||||
"bold": gocui.AttrBold,
|
||||
"reverse": gocui.AttrReverse,
|
||||
"underline": gocui.AttrUnderline,
|
||||
"default": gocui.ColorDefault,
|
||||
"black": gocui.ColorBlack,
|
||||
"red": gocui.ColorRed,
|
||||
"green": gocui.ColorGreen,
|
||||
"yellow": gocui.ColorYellow,
|
||||
"blue": gocui.ColorBlue,
|
||||
"magenta": gocui.ColorMagenta,
|
||||
"cyan": gocui.ColorCyan,
|
||||
"white": gocui.ColorWhite,
|
||||
"bold": gocui.AttrBold,
|
||||
"reverse": gocui.AttrReverse,
|
||||
"underline": gocui.AttrUnderline,
|
||||
"strikethrough": gocui.AttrStrikeThrough,
|
||||
}
|
||||
|
||||
// GetGocuiAttribute gets the gocui color attribute from the string
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package theme
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/jesseduffield/lazygit/pkg/gocui"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestGetGocuiStyle(t *testing.T) {
|
||||
scenarios := []struct {
|
||||
name string
|
||||
keys []string
|
||||
expected gocui.Attribute
|
||||
}{
|
||||
{
|
||||
name: "named color",
|
||||
keys: []string{"red"},
|
||||
expected: gocui.ColorRed,
|
||||
},
|
||||
{
|
||||
name: "named color with modifiers",
|
||||
keys: []string{"red", "bold", "underline"},
|
||||
expected: gocui.ColorRed | gocui.AttrBold | gocui.AttrUnderline,
|
||||
},
|
||||
{
|
||||
name: "strikethrough",
|
||||
keys: []string{"red", "strikethrough"},
|
||||
expected: gocui.ColorRed | gocui.AttrStrikeThrough,
|
||||
},
|
||||
}
|
||||
|
||||
for _, scenario := range scenarios {
|
||||
t.Run(scenario.name, func(t *testing.T) {
|
||||
assert.Equal(t, scenario.expected, GetGocuiStyle(scenario.keys))
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user