Allow dim in theme colors

The faint attribute makes text recede on dark and light backgrounds
alike, without having to pick a gray for each. Let users use it in the
theme.

Some theme colors go through both GetTextStyle and GetGocuiStyle, so
both have to know it.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Stefan HallerandClaude Opus 5.5 committed 2026-09-27 08:16:06 +02:00
1 parent c236214c29
commit 8e1f652a35
5 files changed
+15

No files matched your search

+1
View File
@@ -1017,6 +1017,7 @@ The available attributes are:
- bold - bold
- default - default
- dim # faint text; not supported by every terminal
- reverse # useful for high-contrast - reverse # useful for high-contrast
- underline - underline
- strikethrough - strikethrough
+1
View File
@@ -17,6 +17,7 @@ var gocuiColorMap = map[string]gocui.Attribute{
"cyan": gocui.ColorCyan, "cyan": gocui.ColorCyan,
"white": gocui.ColorWhite, "white": gocui.ColorWhite,
"bold": gocui.AttrBold, "bold": gocui.AttrBold,
"dim": gocui.AttrDim,
"reverse": gocui.AttrReverse, "reverse": gocui.AttrReverse,
"underline": gocui.AttrUnderline, "underline": gocui.AttrUnderline,
"strikethrough": gocui.AttrStrikeThrough, "strikethrough": gocui.AttrStrikeThrough,
+5
View File
@@ -28,6 +28,11 @@ func TestGetGocuiStyle(t *testing.T) {
keys: []string{"red", "strikethrough"}, keys: []string{"red", "strikethrough"},
expected: gocui.ColorRed | gocui.AttrStrikeThrough, expected: gocui.ColorRed | gocui.AttrStrikeThrough,
}, },
{
name: "dim",
keys: []string{"default", "dim"},
expected: gocui.ColorDefault | gocui.AttrDim,
},
} }
for _, scenario := range scenarios { for _, scenario := range scenarios {
+2
View File
@@ -13,6 +13,8 @@ func GetTextStyle(keys []string, background bool) style.TextStyle {
switch key { switch key {
case "bold": case "bold":
s = s.SetBold() s = s.SetBold()
case "dim":
s = s.SetDim()
case "reverse": case "reverse":
s = s.SetReverse() s = s.SetReverse()
case "underline": case "underline":
+6
View File
@@ -39,6 +39,12 @@ func TestGetTextStyle(t *testing.T) {
background: false, background: false,
expected: style.New().SetFg(style.NewRGBColor(color.RGBColor{0x12, 0x34, 0x56, 0})), expected: style.New().SetFg(style.NewRGBColor(color.RGBColor{0x12, 0x34, 0x56, 0})),
}, },
{
name: "dim",
keys: []string{"dim"},
background: false,
expected: style.New().SetDim(),
},
{ {
name: "hex color, bg", name: "hex color, bg",
keys: []string{"#abcdef"}, keys: []string{"#abcdef"},