mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Add the MultiSourceWidget concept
This commit is contained in:
@@ -12,13 +12,11 @@ type HelpfulWidget struct {
|
||||
}
|
||||
|
||||
func NewHelpfulWidget(app *tview.Application, pages *tview.Pages, helpText string) HelpfulWidget {
|
||||
widget := HelpfulWidget{
|
||||
return HelpfulWidget{
|
||||
app: app,
|
||||
helpText: helpText,
|
||||
pages: pages,
|
||||
}
|
||||
|
||||
return widget
|
||||
}
|
||||
|
||||
func (widget *HelpfulWidget) SetView(view *tview.TextView) {
|
||||
|
||||
38
wtf/multisource_widget.go
Normal file
38
wtf/multisource_widget.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package wtf
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type MultiSourceWidget struct {
|
||||
Idx int
|
||||
Sources []string
|
||||
}
|
||||
|
||||
func NewMultiSourceWidget() MultiSourceWidget {
|
||||
return MultiSourceWidget{}
|
||||
}
|
||||
|
||||
/* -------------------- Exported Functions -------------------- */
|
||||
|
||||
func (widget *MultiSourceWidget) CurrentSource() string {
|
||||
return widget.Sources[widget.Idx]
|
||||
}
|
||||
|
||||
func (widget *MultiSourceWidget) LoadSources(module, singular, plural string) {
|
||||
var empty []interface{}
|
||||
|
||||
s := fmt.Sprintf("wtf.mods.%s.%s", module, singular)
|
||||
p := fmt.Sprintf("wtf.mods.%s.%s", module, plural)
|
||||
|
||||
single := Config.UString(s, "")
|
||||
multiple := Config.UList(p, empty)
|
||||
|
||||
asStrs := ToStrs(multiple)
|
||||
|
||||
if single != "" {
|
||||
asStrs = append(asStrs, single)
|
||||
}
|
||||
|
||||
widget.Sources = asStrs
|
||||
}
|
||||
Reference in New Issue
Block a user