Files
lazygit/pkg/gui/style/basic_styles.go
T
Stefan HallerandClaude Opus 5 679fe58e8e Add a dim text style
A later commit shows the hashes of commits outside the bisect range in a
dimmer variant of the default text color. A darker shade of a terminal
palette color can't be derived, because we don't know what the palette
is, so leave the shading to the terminal and use its faint attribute,
SGR 2. In gookit/color that attribute is called OpFuzzy.

Terminals that don't implement SGR 2 render the text in its normal color.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-27 08:16:06 +02:00

71 lines
1.9 KiB
Go

package style
import (
"text/template"
"github.com/gookit/color"
)
var (
FgWhite = FromBasicFg(color.FgWhite)
FgLightWhite = FromBasicFg(color.FgLightWhite)
FgBlack = FromBasicFg(color.FgBlack)
FgBlackLighter = FromBasicFg(color.FgBlack.Light())
FgCyan = FromBasicFg(color.FgCyan)
FgRed = FromBasicFg(color.FgRed)
FgGreen = FromBasicFg(color.FgGreen)
FgBlue = FromBasicFg(color.FgBlue)
FgYellow = FromBasicFg(color.FgYellow)
FgMagenta = FromBasicFg(color.FgMagenta)
FgDefault = FromBasicFg(color.FgDefault)
BgWhite = FromBasicBg(color.BgWhite)
BgBlack = FromBasicBg(color.BgBlack)
BgRed = FromBasicBg(color.BgRed)
BgGreen = FromBasicBg(color.BgGreen)
BgYellow = FromBasicBg(color.BgYellow)
BgBlue = FromBasicBg(color.BgBlue)
BgMagenta = FromBasicBg(color.BgMagenta)
BgCyan = FromBasicBg(color.BgCyan)
BgDefault = FromBasicBg(color.BgDefault)
// will not print any colour escape codes, including the reset escape code
Nothing = New()
AttrUnderline = New().SetUnderline()
AttrBold = New().SetBold()
AttrDim = New().SetDim()
ColorMap = map[string]struct {
Foreground TextStyle
Background TextStyle
}{
"default": {FgDefault, BgDefault},
"black": {FgBlack, BgBlack},
"red": {FgRed, BgRed},
"green": {FgGreen, BgGreen},
"yellow": {FgYellow, BgYellow},
"blue": {FgBlue, BgBlue},
"magenta": {FgMagenta, BgMagenta},
"cyan": {FgCyan, BgCyan},
"white": {FgWhite, BgWhite},
}
)
func FromBasicFg(fg color.Color) TextStyle {
return New().SetFg(NewBasicColor(fg))
}
func FromBasicBg(bg color.Color) TextStyle {
return New().SetBg(NewBasicColor(bg))
}
func TemplateFuncMapAddColors(m template.FuncMap) template.FuncMap {
for k, v := range ColorMap {
m[k] = v.Foreground.Sprint
}
m["underline"] = color.OpUnderscore.Sprint
m["bold"] = color.OpBold.Sprint
return m
}