mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Renormalize the redraw function
Have all instances take a function Update the remaining modules to take this into account Numerous smaller refactors to make some widgets work more or less the same
This commit is contained in:
@@ -5,28 +5,27 @@ import (
|
||||
)
|
||||
|
||||
func (widget *Widget) display(clocks []Clock, dateFormat string, timeFormat string) {
|
||||
if len(clocks) == 0 {
|
||||
title := fmt.Sprintf("\n%s", " no timezone data available")
|
||||
widget.Redraw(widget.CommonSettings().Title, title, true)
|
||||
return
|
||||
}
|
||||
|
||||
str := ""
|
||||
for idx, clock := range clocks {
|
||||
rowColor := widget.settings.colors.rows.odd
|
||||
if len(clocks) == 0 {
|
||||
str = fmt.Sprintf("\n%s", " no timezone data available")
|
||||
} else {
|
||||
|
||||
if idx%2 == 0 {
|
||||
rowColor = widget.settings.colors.rows.even
|
||||
for idx, clock := range clocks {
|
||||
rowColor := widget.settings.colors.rows.odd
|
||||
|
||||
if idx%2 == 0 {
|
||||
rowColor = widget.settings.colors.rows.even
|
||||
}
|
||||
|
||||
str += fmt.Sprintf(
|
||||
" [%s]%-12s %-10s %7s[white]\n",
|
||||
rowColor,
|
||||
clock.Label,
|
||||
clock.Time(timeFormat),
|
||||
clock.Date(dateFormat),
|
||||
)
|
||||
}
|
||||
|
||||
str += fmt.Sprintf(
|
||||
" [%s]%-12s %-10s %7s[white]\n",
|
||||
rowColor,
|
||||
clock.Label,
|
||||
clock.Time(timeFormat),
|
||||
clock.Date(dateFormat),
|
||||
)
|
||||
}
|
||||
|
||||
widget.Redraw(widget.CommonSettings().Title, str, false)
|
||||
widget.Redraw(func() (string, string, bool) { return widget.CommonSettings().Title, str, true })
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user