1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

CenterText function out into utility function

This commit is contained in:
Chris Cummer
2018-04-02 04:45:46 -07:00
committed by Chris Cummer
parent 278bf583c4
commit de7480b221
2 changed files with 1 additions and 11 deletions

View File

@@ -53,13 +53,9 @@ func (widget *Widget) addView() {
widget.View = view
}
func centerText(str string, width int) string {
return fmt.Sprintf("%[1]*s", -width, fmt.Sprintf("%[1]*s", (width+len(str))/2, str))
}
func (widget *Widget) contentFrom(items []Item) string {
if len(items) == 0 {
return fmt.Sprintf("\n\n\n\n\n\n\n%s", centerText("[grey]no one[white]", 52))
return fmt.Sprintf("\n\n\n\n\n\n\n%s", wtf.CenterText("[grey]no one[white]", 52))
}
str := ""