mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Tweaks to the widget presentation
This commit is contained in:
parent
9756e1885f
commit
7b5d06c670
@ -33,7 +33,7 @@ func NewWidget() *Widget {
|
|||||||
func (widget *Widget) Refresh() {
|
func (widget *Widget) Refresh() {
|
||||||
items := Fetch()
|
items := Fetch()
|
||||||
|
|
||||||
widget.View.SetTitle(fmt.Sprintf(" 🐨 Away (%d) ", len(items)))
|
widget.View.SetTitle(fmt.Sprintf(" 👽 Away (%d) ", len(items)))
|
||||||
widget.RefreshedAt = time.Now()
|
widget.RefreshedAt = time.Now()
|
||||||
|
|
||||||
fmt.Fprintf(widget.View, "%s", widget.contentFrom(items))
|
fmt.Fprintf(widget.View, "%s", widget.contentFrom(items))
|
||||||
@ -52,7 +52,15 @@ func (widget *Widget) addView() {
|
|||||||
widget.View = view
|
widget.View = view
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func centerText(str string, width int) string {
|
||||||
|
return fmt.Sprintf("%[1]*s", -width, fmt.Sprintf("%[1]*s", (width+len(str))/2, str))
|
||||||
|
}
|
||||||
|
|
||||||
func (widget *Widget) contentFrom(items []Item) string {
|
func (widget *Widget) contentFrom(items []Item) string {
|
||||||
|
if len(items) == 0 {
|
||||||
|
return fmt.Sprintf("\n\n\n\n\n\n\n%s", centerText("[grey]no one[white]", 52))
|
||||||
|
}
|
||||||
|
|
||||||
str := ""
|
str := ""
|
||||||
|
|
||||||
for _, item := range items {
|
for _, item := range items {
|
||||||
|
@ -35,7 +35,7 @@ func NewWidget() *Widget {
|
|||||||
func (widget *Widget) Refresh() {
|
func (widget *Widget) Refresh() {
|
||||||
events := Fetch()
|
events := Fetch()
|
||||||
|
|
||||||
widget.View.SetTitle(" 🐸 Calendar ")
|
widget.View.SetTitle(" 🍿 Calendar ")
|
||||||
widget.RefreshedAt = time.Now()
|
widget.RefreshedAt = time.Now()
|
||||||
|
|
||||||
fmt.Fprintf(widget.View, "%s", widget.contentFrom(events))
|
fmt.Fprintf(widget.View, "%s", widget.contentFrom(events))
|
||||||
|
@ -32,7 +32,7 @@ func NewWidget() *Widget {
|
|||||||
/* -------------------- Exported Functions -------------------- */
|
/* -------------------- Exported Functions -------------------- */
|
||||||
|
|
||||||
func (widget *Widget) Refresh() {
|
func (widget *Widget) Refresh() {
|
||||||
widget.View.SetTitle(" 🦊 Status ")
|
widget.View.SetTitle(" 🎁 Status ")
|
||||||
widget.RefreshedAt = time.Now()
|
widget.RefreshedAt = time.Now()
|
||||||
|
|
||||||
widget.View.Clear()
|
widget.View.Clear()
|
||||||
|
2
wtf.go
2
wtf.go
@ -43,7 +43,7 @@ func main() {
|
|||||||
weather.Refresh()
|
weather.Refresh()
|
||||||
|
|
||||||
grid := tview.NewGrid()
|
grid := tview.NewGrid()
|
||||||
grid.SetRows(9, 9, 32, 4) // How _high_ the row is, in terminal rows
|
grid.SetRows(9, 9, 33, 3) // How _high_ the row is, in terminal rows
|
||||||
grid.SetColumns(40, 40) // How _wide_ the column is, in terminal columns
|
grid.SetColumns(40, 40) // How _wide_ the column is, in terminal columns
|
||||||
grid.SetBorder(false)
|
grid.SetBorder(false)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user