1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00
wtf/modules/status/widget.go
2019-04-18 18:22:19 -07:00

45 lines
849 B
Go

package status
import (
"github.com/rivo/tview"
"github.com/wtfutil/wtf/wtf"
)
type Widget struct {
wtf.TextWidget
CurrentIcon int
settings *Settings
}
func NewWidget(app *tview.Application, settings *Settings) *Widget {
widget := Widget{
TextWidget: wtf.NewTextWidget(app, settings.common, false),
CurrentIcon: 0,
settings: settings,
}
return &widget
}
/* -------------------- Exported Functions -------------------- */
func (widget *Widget) Refresh() {
widget.View.SetText(widget.animation())
}
/* -------------------- Unexported Functions -------------------- */
func (widget *Widget) animation() string {
icons := []string{"|", "/", "-", "\\", "|"}
next := icons[widget.CurrentIcon]
widget.CurrentIcon = widget.CurrentIcon + 1
if widget.CurrentIcon == len(icons) {
widget.CurrentIcon = 0
}
return next
}