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:
@@ -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),
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user