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

Bringing back the Status widget

This commit is contained in:
Chris Cummer 2018-05-09 08:56:34 -07:00
parent d246cb4c4a
commit 7adc0cdb11
2 changed files with 20 additions and 22 deletions

View File

@ -1,7 +1,7 @@
package status
import (
//"fmt"
"fmt"
"time"
"github.com/olebedev/config"
@ -14,13 +14,13 @@ var Config *config.Config
type Widget struct {
wtf.TextWidget
Current int
CurrentIcon int
}
func NewWidget() *Widget {
widget := Widget{
TextWidget: wtf.NewTextWidget(" πŸŽ‰ Status ", "status", false),
Current: 0,
CurrentIcon: 0,
}
return &widget
@ -33,28 +33,26 @@ func (widget *Widget) Refresh() {
return
}
//_, _, w, _ := widget.View.GetInnerRect()
widget.View.Clear()
//fmt.Fprintf(
//widget.View,
//fmt.Sprintf("%%%ds\n", w-1),
//widget.Version,
//)
fmt.Fprintf(
widget.View,
"\n%s",
widget.animation(),
)
widget.RefreshedAt = time.Now()
}
/* -------------------- Unexported Functions -------------------- */
//func (widget *Widget) animation() string {
//icons := []string{"πŸ‘", "🀜", "πŸ€™", "🀜", "🀘", "🀜", "✊", "🀜", "πŸ‘Œ", "🀜"}
//next := icons[widget.Current]
func (widget *Widget) animation() string {
icons := []string{"πŸ‘", "🀜", "πŸ€™", "🀜", "🀘", "🀜", "✊", "🀜", "πŸ‘Œ", "🀜"}
next := icons[widget.CurrentIcon]
//widget.Current = widget.Current + 1
//if widget.Current == len(icons) {
//widget.Current = 0
//}
widget.CurrentIcon = widget.CurrentIcon + 1
if widget.CurrentIcon == len(icons) {
widget.CurrentIcon = 0
}
//return next
//}
return next
}

View File

@ -12,8 +12,8 @@ var Config *config.Config
type TextWidget struct {
enabled bool
focusable bool
Name string
RefreshedAt time.Time
RefreshInt int