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

@@ -54,10 +54,6 @@ 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(data *owm.CurrentWeatherData) string {
str := fmt.Sprintf("\n")
@@ -71,8 +67,6 @@ func (widget *Widget) contentFrom(data *owm.CurrentWeatherData) string {
str = str + fmt.Sprintf("%10s: %4.1f° C\n", "Current", data.Main.Temp)
str = str + fmt.Sprintf("%10s: %4.1f° C\n", "High", data.Main.TempMax)
str = str + fmt.Sprintf("%10s: %4.1f° C\n", "Low", data.Main.TempMin)
str = str + "\n\n\n\n"
str = str + centerText(fmt.Sprintf("Refreshed at %s", widget.refreshedAt()), 38)
return str
}