mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
A ton of cleanup around how config is handled and go rountines are executed
This commit is contained in:
committed by
Chris Cummer
parent
dd51994d8d
commit
71f8fc789f
55
github/widget.go
Normal file
55
github/widget.go
Normal file
@@ -0,0 +1,55 @@
|
||||
package github
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/gdamore/tcell"
|
||||
"github.com/olebedev/config"
|
||||
"github.com/rivo/tview"
|
||||
"github.com/senorprogrammer/wtf/wtf"
|
||||
)
|
||||
|
||||
var Config *config.Config
|
||||
|
||||
type Widget struct {
|
||||
wtf.BaseWidget
|
||||
View *tview.TextView
|
||||
}
|
||||
|
||||
func NewWidget() *Widget {
|
||||
widget := Widget{
|
||||
BaseWidget: wtf.BaseWidget{
|
||||
Name: "Github",
|
||||
RefreshedAt: time.Now(),
|
||||
RefreshInt: Config.UInt("wtf.github.refreshInterval", 900),
|
||||
},
|
||||
}
|
||||
|
||||
widget.addView()
|
||||
|
||||
return &widget
|
||||
}
|
||||
|
||||
/* -------------------- Exported Functions -------------------- */
|
||||
|
||||
func (widget *Widget) Refresh() {
|
||||
widget.View.SetTitle(fmt.Sprintf(" %s ", widget.Name))
|
||||
widget.RefreshedAt = time.Now()
|
||||
|
||||
widget.View.Clear()
|
||||
fmt.Fprintf(widget.View, "%s", "github")
|
||||
}
|
||||
|
||||
/* -------------------- Unexported Functions -------------------- */
|
||||
|
||||
func (widget *Widget) addView() {
|
||||
view := tview.NewTextView()
|
||||
|
||||
view.SetBorder(true)
|
||||
view.SetBorderColor(tcell.ColorGray)
|
||||
view.SetDynamicColors(true)
|
||||
view.SetTitle(widget.Name)
|
||||
|
||||
widget.View = view
|
||||
}
|
||||
Reference in New Issue
Block a user