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

Widgetized Status

This commit is contained in:
Chris Cummer 2018-03-29 18:06:42 -07:00 committed by Chris Cummer
parent 951da43f99
commit 8a258225c9

View File

@ -2,17 +2,47 @@ package status
import ( import (
"fmt" "fmt"
"time"
"github.com/rivo/tview" "github.com/rivo/tview"
) )
func Widget() tview.Primitive { type Widget struct {
widget := tview.NewTextView() RefreshedAt time.Time
widget.SetBorder(true) View *tview.TextView
widget.SetDynamicColors(true) }
widget.SetTitle(" 🦊 Status ")
func NewWidget() *Widget {
fmt.Fprintf(widget, "%s", "cats and gods\ndogs and tacs") widget := Widget{
RefreshedAt: time.Now(),
return widget }
widget.addView()
return &widget
}
/* -------------------- Exported Functions -------------------- */
func (widget *Widget) Refresh() {
widget.View.SetTitle(" 🦊 Status ")
widget.RefreshedAt = time.Now()
fmt.Fprintf(widget.View, "%s", widget.contentFrom())
}
/* -------------------- Unexported Functions -------------------- */
func (widget *Widget) addView() {
view := tview.NewTextView()
view.SetBorder(true)
view.SetDynamicColors(true)
view.SetTitle(" BambooHR ")
widget.View = view
}
func (widget *Widget) contentFrom() string {
return "cats and gods\ndogs and tacs"
} }