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:
17
colorer.go
17
colorer.go
@ -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))
|
|
||||||
}
|
|
12
utils.go
12
utils.go
@ -1,8 +1,10 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/fatih/color"
|
||||||
"github.com/jesseduffield/gocui"
|
"github.com/jesseduffield/gocui"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -28,3 +30,13 @@ func withPadding(str string, padding int) string {
|
|||||||
}
|
}
|
||||||
return str + strings.Repeat(" ", padding-len(str))
|
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))
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user