1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

Simplify the inclusion of the Common config settings into each module

Signed-off-by: Chris Cummer <chriscummer@me.com>
This commit is contained in:
Chris Cummer
2020-11-26 19:53:21 -08:00
parent f9a06540f1
commit d6a0797bf2
161 changed files with 378 additions and 330 deletions

View File

@@ -15,8 +15,8 @@ func (widget *Widget) display() {
func (widget *Widget) content() (string, string, bool) {
str := ""
newList := checklist.NewChecklist(
widget.settings.common.Sigils.Checkbox.Checked,
widget.settings.common.Sigils.Checkbox.Unchecked,
widget.settings.Sigils.Checkbox.Checked,
widget.settings.Sigils.Checkbox.Unchecked,
)
offset := 0
@@ -45,7 +45,7 @@ func (widget *Widget) formattedItemLine(idx int, currItem *checklist.ChecklistIt
rowColor := widget.RowColor(idx)
if currItem.Checked {
rowColor = widget.settings.common.Colors.CheckboxTheme.Checked
rowColor = widget.settings.Colors.CheckboxTheme.Checked
}
if widget.View.HasFocus() && (currItem == selectedItem) {

View File

@@ -12,7 +12,7 @@ const (
// Settings defines the configuration properties for this module
type Settings struct {
common *cfg.Common
*cfg.Common
filePath string
checked string
@@ -24,7 +24,7 @@ func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *co
common := cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig)
settings := Settings{
common: common,
Common: common,
filePath: ymlConfig.UString("filename"),
checked: ymlConfig.UString("checkedIcon", common.Checkbox.Checked),

View File

@@ -34,12 +34,12 @@ type Widget struct {
// NewWidget creates a new instance of a widget
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
widget := Widget{
ScrollableWidget: view.NewScrollableWidget(app, pages, settings.common),
ScrollableWidget: view.NewScrollableWidget(app, pages, settings.Common),
app: app,
settings: settings,
filePath: settings.filePath,
list: checklist.NewChecklist(settings.common.Sigils.Checkbox.Checked, settings.common.Sigils.Checkbox.Unchecked),
list: checklist.NewChecklist(settings.Sigils.Checkbox.Checked, settings.Sigils.Checkbox.Unchecked),
pages: pages,
}
@@ -219,8 +219,8 @@ func (widget *Widget) modalFocus(form *tview.Form) {
}
func (widget *Widget) modalForm(lbl, text string) *tview.Form {
form := tview.NewForm().SetFieldBackgroundColor(wtf.ColorFor(widget.settings.common.Colors.Background))
form.SetButtonsAlign(tview.AlignCenter).SetButtonTextColor(wtf.ColorFor(widget.settings.common.Colors.Text))
form := tview.NewForm().SetFieldBackgroundColor(wtf.ColorFor(widget.settings.Colors.Background))
form.SetButtonsAlign(tview.AlignCenter).SetButtonTextColor(wtf.ColorFor(widget.settings.Colors.Text))
form.AddInputField(lbl, text, 60, nil, nil)