mirror of
				https://github.com/taigrr/wtf
				synced 2025-01-18 04:03:14 -08:00 
			
		
		
		
	Bringing back the Status widget
This commit is contained in:
		
							parent
							
								
									d246cb4c4a
								
							
						
					
					
						commit
						7adc0cdb11
					
				@ -1,7 +1,7 @@
 | 
			
		||||
package status
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	//"fmt"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"time"
 | 
			
		||||
 | 
			
		||||
	"github.com/olebedev/config"
 | 
			
		||||
@ -14,13 +14,13 @@ var Config *config.Config
 | 
			
		||||
type Widget struct {
 | 
			
		||||
	wtf.TextWidget
 | 
			
		||||
 | 
			
		||||
	Current int
 | 
			
		||||
	CurrentIcon int
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewWidget() *Widget {
 | 
			
		||||
	widget := Widget{
 | 
			
		||||
		TextWidget: wtf.NewTextWidget(" π Status ", "status", false),
 | 
			
		||||
		Current:    0,
 | 
			
		||||
		TextWidget:  wtf.NewTextWidget(" π Status ", "status", false),
 | 
			
		||||
		CurrentIcon: 0,
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return &widget
 | 
			
		||||
@ -33,28 +33,26 @@ func (widget *Widget) Refresh() {
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	//_, _, w, _ := widget.View.GetInnerRect()
 | 
			
		||||
 | 
			
		||||
	widget.View.Clear()
 | 
			
		||||
	//fmt.Fprintf(
 | 
			
		||||
	//widget.View,
 | 
			
		||||
	//fmt.Sprintf("%%%ds\n", w-1),
 | 
			
		||||
	//widget.Version,
 | 
			
		||||
	//)
 | 
			
		||||
	fmt.Fprintf(
 | 
			
		||||
		widget.View,
 | 
			
		||||
		"\n%s",
 | 
			
		||||
		widget.animation(),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	widget.RefreshedAt = time.Now()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* -------------------- Unexported Functions -------------------- */
 | 
			
		||||
 | 
			
		||||
//func (widget *Widget) animation() string {
 | 
			
		||||
//icons := []string{"π", "π€", "π€", "π€", "π€", "π€", "β", "π€", "π", "π€"}
 | 
			
		||||
//next := icons[widget.Current]
 | 
			
		||||
func (widget *Widget) animation() string {
 | 
			
		||||
	icons := []string{"π", "π€", "π€", "π€", "π€", "π€", "β", "π€", "π", "π€"}
 | 
			
		||||
	next := icons[widget.CurrentIcon]
 | 
			
		||||
 | 
			
		||||
//widget.Current = widget.Current + 1
 | 
			
		||||
//if widget.Current == len(icons) {
 | 
			
		||||
//widget.Current = 0
 | 
			
		||||
//}
 | 
			
		||||
	widget.CurrentIcon = widget.CurrentIcon + 1
 | 
			
		||||
	if widget.CurrentIcon == len(icons) {
 | 
			
		||||
		widget.CurrentIcon = 0
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
//return next
 | 
			
		||||
//}
 | 
			
		||||
	return next
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -11,9 +11,9 @@ import (
 | 
			
		||||
var Config *config.Config
 | 
			
		||||
 | 
			
		||||
type TextWidget struct {
 | 
			
		||||
	enabled bool
 | 
			
		||||
	enabled   bool
 | 
			
		||||
	focusable bool
 | 
			
		||||
 | 
			
		||||
	focusable   bool
 | 
			
		||||
	Name        string
 | 
			
		||||
	RefreshedAt time.Time
 | 
			
		||||
	RefreshInt  int
 | 
			
		||||
 | 
			
		||||
		Loadingβ¦
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user