1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-30 03:23:08 +03:00

Add color functions to templates funcMaps

This commit is contained in:
Elwardi
2021-08-09 11:52:00 +01:00
parent b5d8849c06
commit e8e4fa5957
3 changed files with 12 additions and 7 deletions

View File

@ -2,6 +2,7 @@ package style
import (
"github.com/gookit/color"
"text/template"
)
var (
@ -51,3 +52,12 @@ func FromBasicFg(fg color.Color) TextStyle {
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
}