Simon Vieille
433cfda295
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
35 lines
694 B
Go
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)
|
|
}
|