mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Decouple modules from global config
Rather than referencing wtc.Config, instead pass the global config Also, look up config for the module early and pass that in sooner, to deal with fewer long paths and get rid of the ConfigKey variable
This commit is contained in:
@@ -14,7 +14,6 @@ type TextWidget struct {
|
||||
enabled bool
|
||||
focusable bool
|
||||
focusChar string
|
||||
key string
|
||||
name string
|
||||
refreshInterval int
|
||||
|
||||
@@ -31,7 +30,6 @@ func NewTextWidget(app *tview.Application, commonSettings *cfg.Common, focusable
|
||||
enabled: commonSettings.Enabled,
|
||||
focusable: focusable,
|
||||
focusChar: commonSettings.FocusChar(),
|
||||
key: commonSettings.ConfigKey,
|
||||
name: commonSettings.Name,
|
||||
refreshInterval: commonSettings.RefreshInterval,
|
||||
}
|
||||
@@ -92,10 +90,6 @@ func (widget *TextWidget) IsPositionable() bool {
|
||||
return widget.Position.IsValid()
|
||||
}
|
||||
|
||||
func (widget *TextWidget) Key() string {
|
||||
return widget.key
|
||||
}
|
||||
|
||||
func (widget *TextWidget) Name() string {
|
||||
return widget.name
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ func ValidateWidgets(widgets []Wtfable) (bool, error) {
|
||||
|
||||
for _, widget := range widgets {
|
||||
if widget.Enabled() && !widget.IsPositionable() {
|
||||
errStr := fmt.Sprintf("Widget config has invalid values: %s", widget.Key())
|
||||
errStr := fmt.Sprintf("Widget config has invalid values: %s", widget.Name())
|
||||
log.Fatalln(errStr)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ type Wtfable interface {
|
||||
BorderColor() string
|
||||
FocusChar() string
|
||||
Focusable() bool
|
||||
Key() string
|
||||
Name() string
|
||||
SetFocusChar(string)
|
||||
TextView() *tview.TextView
|
||||
|
||||
Reference in New Issue
Block a user