mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Remove complexity from a lot of string display statements
This commit is contained in:
@@ -9,32 +9,31 @@ import (
|
||||
)
|
||||
|
||||
func (widget *Widget) display() {
|
||||
widget.View.Clear()
|
||||
|
||||
if widget.apiKeyValid() == false {
|
||||
fmt.Fprintf(widget.View, "%s", " Environment variable WTF_OWM_API_KEY is not set")
|
||||
widget.View.SetText(" Environment variable WTF_OWM_API_KEY is not set")
|
||||
return
|
||||
}
|
||||
|
||||
cityData := widget.currentData()
|
||||
if cityData == nil {
|
||||
fmt.Fprintf(widget.View, "%s", " Weather data is unavailable (1)")
|
||||
widget.View.SetText(" Weather data is unavailable: no city data")
|
||||
return
|
||||
}
|
||||
|
||||
if len(cityData.Weather) == 0 {
|
||||
fmt.Fprintf(widget.View, "%s", " Weather data is unavailable (2)")
|
||||
widget.View.SetText(" Weather data is unavailable: no weather data")
|
||||
return
|
||||
}
|
||||
|
||||
widget.View.SetTitle(widget.title(cityData))
|
||||
|
||||
str := wtf.SigilStr(len(widget.Data), widget.Idx, widget.View) + "\n"
|
||||
str = str + widget.description(cityData) + "\n\n"
|
||||
str = str + widget.temperatures(cityData) + "\n"
|
||||
str = str + widget.sunInfo(cityData)
|
||||
content := wtf.SigilStr(len(widget.Data), widget.Idx, widget.View) + "\n"
|
||||
content = content + widget.description(cityData) + "\n\n"
|
||||
content = content + widget.temperatures(cityData) + "\n"
|
||||
content = content + widget.sunInfo(cityData)
|
||||
|
||||
fmt.Fprintf(widget.View, "%s", str)
|
||||
widget.View.SetText(content)
|
||||
}
|
||||
|
||||
func (widget *Widget) description(cityData *owm.CurrentWeatherData) string {
|
||||
@@ -73,5 +72,5 @@ func (widget *Widget) temperatures(cityData *owm.CurrentWeatherData) string {
|
||||
}
|
||||
|
||||
func (widget *Widget) title(cityData *owm.CurrentWeatherData) string {
|
||||
return fmt.Sprintf(" %s %s ", widget.icon(cityData), cityData.Name)
|
||||
return fmt.Sprintf(" %s %s ", widget.icon(cityData), cityData.Name)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user