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

@@ -12,7 +12,7 @@ const (
// Settings defines the configuration properties for this module
type Settings struct {
common *cfg.Common
*cfg.Common
filePaths []interface{}
format bool
@@ -24,7 +24,7 @@ type Settings struct {
func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings {
settings := Settings{
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
Common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
filePaths: ymlConfig.UList("filePaths"),
format: ymlConfig.UBool("format", false),

View File

@@ -31,14 +31,14 @@ type Widget struct {
// NewWidget creates a new instance of a widget
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
widget := Widget{
MultiSourceWidget: view.NewMultiSourceWidget(settings.common, "filePath", "filePaths"),
TextWidget: view.NewTextWidget(app, pages, settings.common),
MultiSourceWidget: view.NewMultiSourceWidget(settings.Common, "filePath", "filePaths"),
TextWidget: view.NewTextWidget(app, pages, settings.Common),
settings: settings,
}
// Don't use a timer for this widget, watch for filesystem changes instead
widget.settings.common.RefreshInterval = 0
widget.settings.RefreshInterval = 0
widget.initializeKeyboardControls()
@@ -64,12 +64,12 @@ func (widget *Widget) Refresh() {
func (widget *Widget) content() (string, string, bool) {
title := fmt.Sprintf(
"[%s]%s[white]",
widget.settings.common.Colors.TextTheme.Title,
widget.settings.Colors.TextTheme.Title,
widget.CurrentSource(),
)
_, _, width, _ := widget.View.GetRect()
text := widget.settings.common.PaginationMarker(len(widget.Sources), widget.Idx, width) + "\n"
text := widget.settings.PaginationMarker(len(widget.Sources), widget.Idx, width) + "\n"
if widget.settings.format {
text += widget.formattedText()