mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
First pass at multi-Git repos. Works; no tick marks yet
This commit is contained in:
@@ -8,10 +8,10 @@ import (
|
||||
"github.com/senorprogrammer/wtf/wtf"
|
||||
)
|
||||
|
||||
func (widget *Widget) display(data []*owm.CurrentWeatherData) {
|
||||
func (widget *Widget) display() {
|
||||
widget.View.Clear()
|
||||
|
||||
cityData := widget.currentCityData(data)
|
||||
cityData := widget.currentData()
|
||||
|
||||
if len(cityData.Weather) == 0 {
|
||||
fmt.Fprintf(widget.View, "%s", " Weather data is unavailable.")
|
||||
@@ -20,7 +20,7 @@ func (widget *Widget) display(data []*owm.CurrentWeatherData) {
|
||||
|
||||
widget.View.SetTitle(widget.title(cityData))
|
||||
|
||||
str := widget.tickMarks(data) + "\n"
|
||||
str := widget.tickMarks(widget.Data) + "\n"
|
||||
str = str + widget.description(cityData) + "\n\n"
|
||||
str = str + widget.temperatures(cityData) + "\n"
|
||||
str = str + widget.sunInfo(cityData)
|
||||
@@ -59,10 +59,10 @@ func (widget *Widget) tickMarks(data []*owm.CurrentWeatherData) string {
|
||||
str := ""
|
||||
|
||||
if len(data) > 1 {
|
||||
tickMarks := strings.Repeat("*", len(data))
|
||||
tickMarks = tickMarks[:widget.Idx] + "_" + tickMarks[widget.Idx+1:]
|
||||
marks := strings.Repeat("*", len(data))
|
||||
marks = marks[:widget.Idx] + "_" + marks[widget.Idx+1:]
|
||||
|
||||
str = "[lightblue]" + fmt.Sprintf(wtf.RightAlignFormat(widget.View), tickMarks) + "[white]"
|
||||
str = "[lightblue]" + fmt.Sprintf(wtf.RightAlignFormat(widget.View), marks) + "[white]"
|
||||
}
|
||||
|
||||
return str
|
||||
|
||||
@@ -62,7 +62,7 @@ func (widget *Widget) Refresh() {
|
||||
|
||||
widget.Data = widget.Fetch(wtf.ToInts(Config.UList("wtf.mods.weather.cityids", widget.defaultCityCodes())))
|
||||
|
||||
widget.display(widget.Data)
|
||||
widget.display()
|
||||
widget.RefreshedAt = time.Now()
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ func (widget *Widget) Next() {
|
||||
widget.Idx = 0
|
||||
}
|
||||
|
||||
widget.display(widget.Data)
|
||||
widget.display()
|
||||
}
|
||||
|
||||
// Prev displays data for the previous city in the list. If the previous city is the first
|
||||
@@ -85,13 +85,13 @@ func (widget *Widget) Prev() {
|
||||
widget.Idx = len(widget.Data) - 1
|
||||
}
|
||||
|
||||
widget.display(widget.Data)
|
||||
widget.display()
|
||||
}
|
||||
|
||||
/* -------------------- Unexported Functions -------------------- */
|
||||
|
||||
func (widget *Widget) currentCityData(data []*owm.CurrentWeatherData) *owm.CurrentWeatherData {
|
||||
return data[widget.Idx]
|
||||
func (widget *Widget) currentData() *owm.CurrentWeatherData {
|
||||
return widget.Data[widget.Idx]
|
||||
}
|
||||
|
||||
func (widget *Widget) currentWeather(apiKey string, cityCode int) (*owm.CurrentWeatherData, error) {
|
||||
@@ -189,15 +189,13 @@ func (widget *Widget) keyboardIntercept(event *tcell.EventKey) *tcell.EventKey {
|
||||
switch event.Key() {
|
||||
case tcell.KeyLeft:
|
||||
widget.Prev()
|
||||
return nil
|
||||
case tcell.KeyRight:
|
||||
widget.Next()
|
||||
return nil
|
||||
default:
|
||||
return event
|
||||
}
|
||||
|
||||
return event
|
||||
}
|
||||
|
||||
func (widget *Widget) refreshedAt() string {
|
||||
return widget.RefreshedAt.Format("15:04:05")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user