mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
41
modules/status/widget.go
Normal file
41
modules/status/widget.go
Normal file
@@ -0,0 +1,41 @@
|
||||
package status
|
||||
|
||||
import (
|
||||
"github.com/rivo/tview"
|
||||
"github.com/wtfutil/wtf/wtf"
|
||||
)
|
||||
|
||||
type Widget struct {
|
||||
wtf.TextWidget
|
||||
|
||||
CurrentIcon int
|
||||
}
|
||||
|
||||
func NewWidget(app *tview.Application) *Widget {
|
||||
widget := Widget{
|
||||
TextWidget: wtf.NewTextWidget(app, "Status", "status", false),
|
||||
CurrentIcon: 0,
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user