mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Streamlining the widget creation process a bit more. Coords into config
This commit is contained in:
committed by
Chris Cummer
parent
cbf5b45c62
commit
9bda045ce1
@@ -7,4 +7,8 @@ import (
|
||||
type TextViewer interface {
|
||||
Enabler
|
||||
TextView() *tview.TextView
|
||||
Top() int
|
||||
Left() int
|
||||
Width() int
|
||||
Height() int
|
||||
}
|
||||
|
||||
@@ -11,20 +11,39 @@ import (
|
||||
var Config *config.Config
|
||||
|
||||
type Position struct {
|
||||
Top int
|
||||
Left int
|
||||
Width int
|
||||
Height int
|
||||
top int
|
||||
left int
|
||||
width int
|
||||
height int
|
||||
}
|
||||
|
||||
func (pos *Position) Top() int {
|
||||
return pos.top
|
||||
}
|
||||
|
||||
func (pos *Position) Left() int {
|
||||
return pos.left
|
||||
}
|
||||
|
||||
func (pos *Position) Width() int {
|
||||
return pos.width
|
||||
}
|
||||
|
||||
func (pos *Position) Height() int {
|
||||
return pos.height
|
||||
}
|
||||
|
||||
/* -------------------- TextWidget -------------------- */
|
||||
|
||||
type TextWidget struct {
|
||||
enabled bool
|
||||
|
||||
Name string
|
||||
Position Position
|
||||
RefreshedAt time.Time
|
||||
RefreshInt int
|
||||
View *tview.TextView
|
||||
|
||||
Position
|
||||
}
|
||||
|
||||
func NewTextWidget(name string, configKey string) TextWidget {
|
||||
@@ -32,6 +51,12 @@ func NewTextWidget(name string, configKey string) TextWidget {
|
||||
enabled: Config.UBool(fmt.Sprintf("wtf.%s.enabled", configKey), false),
|
||||
Name: name,
|
||||
RefreshInt: Config.UInt(fmt.Sprintf("wtf.%s.refreshInterval", configKey)),
|
||||
Position: Position{
|
||||
top: Config.UInt(fmt.Sprintf("wtf.%s.position.top", configKey)),
|
||||
left: Config.UInt(fmt.Sprintf("wtf.%s.position.left", configKey)),
|
||||
height: Config.UInt(fmt.Sprintf("wtf.%s.position.height", configKey)),
|
||||
width: Config.UInt(fmt.Sprintf("wtf.%s.position.width", configKey)),
|
||||
},
|
||||
}
|
||||
|
||||
return widget
|
||||
|
||||
Reference in New Issue
Block a user