diff options
author | Elwardi <elwardifadeli@gmail.com> | 2021-08-09 11:52:00 +0100 |
---|---|---|
committer | Elwardi <elwardifadeli@gmail.com> | 2021-08-09 11:52:00 +0100 |
commit | e8e4fa59572915f669c5daf272bb5721f53de2d7 (patch) | |
tree | 351e8c1e4cb8c93eaccb4df9669961d0a5c7913d /pkg/gui/style | |
parent | b5d8849c06de3d0ea410e0ba03e66b101b1ec626 (diff) |
Add color functions to templates funcMaps
Diffstat (limited to 'pkg/gui/style')
-rw-r--r-- | pkg/gui/style/basic_styles.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/pkg/gui/style/basic_styles.go b/pkg/gui/style/basic_styles.go index 373172a8b..92b034f06 100644 --- a/pkg/gui/style/basic_styles.go +++ b/pkg/gui/style/basic_styles.go @@ -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 +} |