mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Widgetized Status
This commit is contained in:
parent
951da43f99
commit
8a258225c9
@ -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"
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user