From 28505dddaf221cdd05f3a044f58ced49f132a5e1 Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Fri, 10 Aug 2018 22:09:10 +1000 Subject: [PATCH] move color functions into utils --- colorer.go | 17 ----------------- utils.go | 12 ++++++++++++ 2 files changed, 12 insertions(+), 17 deletions(-) delete mode 100644 colorer.go diff --git a/colorer.go b/colorer.go deleted file mode 100644 index 2b9142264..000000000 --- a/colorer.go +++ /dev/null @@ -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)) -} diff --git a/utils.go b/utils.go index 08d27806d..1ab5a9ed2 100644 --- a/utils.go +++ b/utils.go @@ -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)) +}