1
0
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:
Chris Cummer
2018-04-04 18:02:59 -07:00
committed by Chris Cummer
parent dd51994d8d
commit 71f8fc789f
13 changed files with 99 additions and 30 deletions

55
github/widget.go Normal file
View 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
}