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:
@@ -18,13 +18,13 @@ func (widget *Widget) content() (string, string, bool) {
|
||||
|
||||
title := fmt.Sprintf(
|
||||
"%s - %s[white]",
|
||||
widget.settings.common.Colors.TextTheme.Title,
|
||||
widget.settings.Colors.TextTheme.Title,
|
||||
repoData.Repository,
|
||||
)
|
||||
|
||||
_, _, width, _ := widget.View.GetRect()
|
||||
str := widget.settings.common.PaginationMarker(len(widget.Data), widget.Idx, width) + "\n"
|
||||
str += fmt.Sprintf(" [%s]Branch:Bookmark[white]\n", widget.settings.common.Colors.Subheading)
|
||||
str := widget.settings.PaginationMarker(len(widget.Data), widget.Idx, width) + "\n"
|
||||
str += fmt.Sprintf(" [%s]Branch:Bookmark[white]\n", widget.settings.Colors.Subheading)
|
||||
str += fmt.Sprintf(" %s:%s\n", repoData.Branch, repoData.Bookmark)
|
||||
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)
|
||||
|
||||
@@ -11,7 +11,7 @@ const (
|
||||
)
|
||||
|
||||
type Settings struct {
|
||||
common *cfg.Common
|
||||
*cfg.Common
|
||||
|
||||
commitCount int `help:"The number of past commits to display." optional:"true"`
|
||||
commitFormat string `help:"The string format for the commit message." optional:"true"`
|
||||
@@ -21,7 +21,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]{rev}:{phase} [white]{desc|firstline|strip} [grey]{author|person} {date|age}[white]"),
|
||||
|
||||
@@ -27,8 +27,8 @@ 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, "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