1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-06-23 00:39:13 +02:00

move color functions into utils

This commit is contained in:
Jesse Duffield
2018-08-10 22:09:10 +10:00
parent 95b7c1d0a4
commit 28505dddaf
2 changed files with 12 additions and 17 deletions

View File

@ -1,17 +0,0 @@
package main
import (
"fmt"
"github.com/fatih/color"
)
func coloredString(str string, colorAttribute color.Attribute) string {
colour := color.New(colorAttribute)
return coloredStringDirect(str, colour)
}
// used for aggregating a few color attributes rather than just sending a single one
func coloredStringDirect(str string, colour *color.Color) string {
return colour.SprintFunc()(fmt.Sprint(str))
}

View File

@ -1,8 +1,10 @@
package main
import (
"fmt"
"strings"
"github.com/fatih/color"
"github.com/jesseduffield/gocui"
)
@ -28,3 +30,13 @@ func withPadding(str string, padding int) string {
}
return str + strings.Repeat(" ", padding-len(str))
}
func coloredString(str string, colorAttribute color.Attribute) string {
colour := color.New(colorAttribute)
return coloredStringDirect(str, colour)
}
// used for aggregating a few color attributes rather than just sending a single one
func coloredStringDirect(str string, colour *color.Color) string {
return colour.SprintFunc()(fmt.Sprint(str))
}