i3-blocks-go/rendering/text.go
Simon Vieille 433cfda295
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
remove Emoji func; add FontAwesome func
2022-08-29 11:57:15 +02:00

35 lines
694 B
Go

package rendering
import (
"fmt"
)
type FB struct {
Foreground string
Background string
}
func Text(text string, fb FB) string {
if fb.Foreground == "" {
fb.Foreground = Color("default_foreground")
}
if fb.Background == "" {
fb.Background = Color("default_background")
}
return fmt.Sprintf(`<span background="%s" foreground="%s">%s</span>`, fb.Background, fb.Foreground, text)
}
func TextWithPadding(text string, fb FB) string {
return Text(fmt.Sprintf(" %s ", text), fb)
}
func TextWithLeftPadding(text string, fb FB) string {
return Text(fmt.Sprintf(" %s", text), fb)
}
func TextWithRightPadding(text string, fb FB) string {
return Text(fmt.Sprintf("%s ", text), fb)
}