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

WIP Git widget

This commit is contained in:
Chris Cummer 2018-03-31 20:04:09 -07:00 committed by Chris Cummer
parent d3cd19fd8f
commit f6e7a2c030
6 changed files with 84 additions and 1 deletions

View File

@ -36,6 +36,7 @@ func (widget *Widget) Refresh() {
widget.View.SetTitle(fmt.Sprintf(" 👽 Away (%d) ", len(items)))
widget.RefreshedAt = time.Now()
widget.View.Clear()
fmt.Fprintf(widget.View, "%s", widget.contentFrom(items))
}

View File

@ -38,6 +38,7 @@ func (widget *Widget) Refresh() {
widget.View.SetTitle(" 🍿 Calendar ")
widget.RefreshedAt = time.Now()
widget.View.Clear()
fmt.Fprintf(widget.View, "%s", widget.contentFrom(events))
}

View File

@ -0,0 +1,75 @@
package git
import (
//"fmt"
"time"
"github.com/rivo/tview"
"github.com/senorprogrammer/wtf/wtf"
)
type Widget struct {
wtf.BaseWidget
View *tview.TextView
}
func NewWidget() *Widget {
widget := Widget{
BaseWidget: wtf.BaseWidget{
Name: "Git",
RefreshedAt: time.Now(),
RefreshInterval: 10,
},
}
widget.addView()
go widget.refresher()
return &widget
}
/* -------------------- Exported Functions -------------------- */
func (widget *Widget) Refresh() {
//data := Fetch()
widget.View.SetTitle(" 🙈 Git ")
widget.RefreshedAt = time.Now()
widget.View.Clear()
//fmt.Fprintf(widget.View, "%s", widget.contentFrom(data))
}
/* -------------------- Unexported Functions -------------------- */
func (widget *Widget) addView() {
view := tview.NewTextView()
view.SetBorder(true)
view.SetDynamicColors(true)
view.SetTitle(widget.Name)
widget.View = view
}
func (widget *Widget) contentFrom(data map[string]string) string {
str := "\n"
str = str + "This is git"
return str
}
func (widget *Widget) refresher() {
tick := time.NewTicker(time.Duration(widget.RefreshInterval) * time.Minute)
quit := make(chan struct{})
for {
select {
case <-tick.C:
widget.Refresh()
case <-quit:
tick.Stop()
return
}
}
}

View File

@ -38,7 +38,6 @@ func (widget *Widget) Refresh() {
widget.RefreshedAt = time.Now()
widget.View.Clear()
fmt.Fprintf(widget.View, "%s", widget.contentFrom(data))
}

View File

@ -95,6 +95,8 @@ func icon(data *owm.CurrentWeatherData) string {
icon = "🌤"
case "fog":
icon = "🌫"
case "haze":
icon = "🌫"
case "heavy rain":
icon = "💦"
case "heavy snow":

5
wtf.go
View File

@ -6,6 +6,7 @@ import (
"github.com/rivo/tview"
"github.com/senorprogrammer/wtf/bamboohr"
"github.com/senorprogrammer/wtf/gcal"
"github.com/senorprogrammer/wtf/git"
"github.com/senorprogrammer/wtf/security"
"github.com/senorprogrammer/wtf/status"
"github.com/senorprogrammer/wtf/weather"
@ -33,6 +34,9 @@ func main() {
cal := gcal.NewWidget()
cal.Refresh()
git := git.NewWidget()
git.Refresh()
sec := security.NewWidget()
sec.Refresh()
@ -49,6 +53,7 @@ func main() {
grid.AddItem(bamboo.View, 0, 0, 2, 1, 0, 0, false)
grid.AddItem(cal.View, 2, 0, 1, 1, 0, 0, false)
grid.AddItem(git.View, 0, 2, 3, 1, 0, 0, false)
grid.AddItem(stat.View, 3, 0, 2, 3, 0, 0, false)
grid.AddItem(weather.View, 0, 1, 1, 1, 0, 0, false)
grid.AddItem(sec.View, 1, 1, 1, 1, 0, 0, false)