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

39 lines
756 B
Go

package unknown
import (
"fmt"
"github.com/rivo/tview"
"github.com/wtfutil/wtf/wtf"
)
type Widget struct {
wtf.TextWidget
app *tview.Application
settings *Settings
}
func NewWidget(app *tview.Application, name string, settings *Settings) *Widget {
widget := Widget{
TextWidget: wtf.NewTextWidget(app, settings.common, false),
app: app,
settings: settings,
}
return &widget
}
/* -------------------- Exported Functions -------------------- */
func (widget *Widget) Refresh() {
widget.app.QueueUpdateDraw(func() {
widget.View.SetTitle(widget.ContextualTitle(fmt.Sprintf("%s", widget.Name())))
widget.View.Clear()
content := fmt.Sprintf("Widget %s does not exist", widget.Name())
widget.View.SetText(content)
})
}