diff --git a/status/widget.go b/status/widget.go index cc602e4a..19b09ec8 100644 --- a/status/widget.go +++ b/status/widget.go @@ -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, + TextWidget: wtf.NewTextWidget(" 🎉 Status ", "status", false), + 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 +} diff --git a/wtf/text_widget.go b/wtf/text_widget.go index 1f2a7164..266b2b4f 100644 --- a/wtf/text_widget.go +++ b/wtf/text_widget.go @@ -11,9 +11,9 @@ import ( var Config *config.Config type TextWidget struct { - enabled bool + enabled bool + focusable bool - focusable bool Name string RefreshedAt time.Time RefreshInt int