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:
@@ -23,8 +23,8 @@ func (widget *Widget) content() (string, string, bool) {
|
||||
)
|
||||
|
||||
_, _, width, _ := widget.View.GetRect()
|
||||
str := widget.settings.common.PaginationMarker(len(widget.GitRepos), widget.Idx, width) + "\n"
|
||||
str += fmt.Sprintf(" [%s]Branch[white]\n", widget.settings.common.Colors.Subheading)
|
||||
str := widget.settings.PaginationMarker(len(widget.GitRepos), widget.Idx, width) + "\n"
|
||||
str += fmt.Sprintf(" [%s]Branch[white]\n", widget.settings.Colors.Subheading)
|
||||
str += fmt.Sprintf(" %s", repoData.Branch)
|
||||
str += "\n"
|
||||
str += widget.formatChanges(repoData.ChangedFiles)
|
||||
@@ -35,7 +35,7 @@ func (widget *Widget) content() (string, string, bool) {
|
||||
}
|
||||
|
||||
func (widget *Widget) formatChanges(data []string) string {
|
||||
str := fmt.Sprintf(" [%s]Changed Files[white]\n", widget.settings.common.Colors.Subheading)
|
||||
str := fmt.Sprintf(" [%s]Changed Files[white]\n", widget.settings.Colors.Subheading)
|
||||
|
||||
if len(data) == 1 {
|
||||
str += " [grey]none[white]\n"
|
||||
@@ -72,7 +72,7 @@ func (widget *Widget) formatChange(line string) string {
|
||||
}
|
||||
|
||||
func (widget *Widget) formatCommits(data []string) string {
|
||||
str := fmt.Sprintf(" [%s]Recent Commits[white]\n", widget.settings.common.Colors.Subheading)
|
||||
str := fmt.Sprintf(" [%s]Recent Commits[white]\n", widget.settings.Colors.Subheading)
|
||||
|
||||
for _, line := range data {
|
||||
str += widget.formatCommit(line)
|
||||
|
||||
@@ -12,7 +12,7 @@ const (
|
||||
)
|
||||
|
||||
type Settings struct {
|
||||
common *cfg.Common
|
||||
*cfg.Common
|
||||
|
||||
commitCount int `help:"The number of past commits to display." values:"A positive integer, 0..n." optional:"true"`
|
||||
commitFormat string `help:"The string format for the commit message." optional:"true"`
|
||||
@@ -22,7 +22,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),
|
||||
|
||||
commitCount: ymlConfig.UInt("commitCount", 10),
|
||||
commitFormat: ymlConfig.UString("commitFormat", "[forestgreen]%h [white]%s [grey]%an on %cd[white]"),
|
||||
|
||||
@@ -30,8 +30,8 @@ type Widget struct {
|
||||
|
||||
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
||||
widget := Widget{
|
||||
MultiSourceWidget: view.NewMultiSourceWidget(settings.common, "repository", "repositories"),
|
||||
TextWidget: view.NewTextWidget(app, pages, settings.common),
|
||||
MultiSourceWidget: view.NewMultiSourceWidget(settings.Common, "repository", "repositories"),
|
||||
TextWidget: view.NewTextWidget(app, pages, settings.Common),
|
||||
|
||||
app: app,
|
||||
pages: pages,
|
||||
|
||||
Reference in New Issue
Block a user