diff --git a/git/display.go b/git/display.go index 0894d32a..3fbd0873 100644 --- a/git/display.go +++ b/git/display.go @@ -20,7 +20,7 @@ func (widget *Widget) display() { title := fmt.Sprintf("[green]%s[white]\n", repoData.Repository) widget.View.SetTitle(fmt.Sprintf(" Git: %s ", title)) - str := widget.tickMarks(widget.Data) + "\n" + str := wtf.SygilStr(len(widget.Data), widget.Idx, widget.View) + "\n" str = str + " [red]Branch[white]\n" str = str + fmt.Sprintf(" %s", repoData.Branch) str = str + "\n" @@ -83,16 +83,3 @@ func (widget *Widget) formatCommits(data []string) string { func (widget *Widget) formatCommit(line string) string { return fmt.Sprintf(" %s\n", strings.Replace(line, "\"", "", -1)) } - -func (widget *Widget) tickMarks(data []*GitRepo) string { - str := "" - - if len(data) > 1 { - marks := strings.Repeat("*", len(data)) - marks = marks[:widget.Idx] + "_" + marks[widget.Idx+1:] - - str = "[lightblue]" + fmt.Sprintf(wtf.RightAlignFormat(widget.View), marks) + "[white]" - } - - return str -} diff --git a/github/display.go b/github/display.go index 045f3b8b..7f246c22 100644 --- a/github/display.go +++ b/github/display.go @@ -2,7 +2,6 @@ package github import ( "fmt" - "strings" "github.com/senorprogrammer/wtf/wtf" ) @@ -18,7 +17,7 @@ func (widget *Widget) display() { widget.View.SetTitle(fmt.Sprintf(" Github: %s ", widget.title(repo))) - str := widget.tickMarks(widget.Data) + "\n" + str := wtf.SygilStr(len(widget.Data), widget.Idx, widget.View) + "\n" str = str + " [red]Open Review Requests[white]\n" str = str + widget.prsForReview(repo, Config.UString("wtf.mods.github.username")) str = str + "\n" @@ -72,19 +71,6 @@ func (widget *Widget) prsForReview(repo *GithubRepo, username string) string { return str } -func (widget *Widget) tickMarks(data []*GithubRepo) string { - str := "" - - if len(data) > 1 { - marks := strings.Repeat("*", len(data)) - marks = marks[:widget.Idx] + "_" + marks[widget.Idx+1:] - - str = "[lightblue]" + fmt.Sprintf(wtf.RightAlignFormat(widget.View), marks) + "[white]" - } - - return str -} - func (widget *Widget) title(repo *GithubRepo) string { return fmt.Sprintf("[green]%s - %s[white]", repo.Owner, repo.Name) } diff --git a/weather/display.go b/weather/display.go index 874671eb..df06f0ad 100644 --- a/weather/display.go +++ b/weather/display.go @@ -24,7 +24,7 @@ func (widget *Widget) display() { widget.View.SetTitle(widget.title(cityData)) - str := widget.tickMarks(widget.Data) + "\n" + str := wtf.SygilStr(len(widget.Data), widget.Idx, widget.View) + "\n" str = str + widget.description(cityData) + "\n\n" str = str + widget.temperatures(cityData) + "\n" str = str + widget.sunInfo(cityData) @@ -67,19 +67,6 @@ func (widget *Widget) temperatures(cityData *owm.CurrentWeatherData) string { return str } -func (widget *Widget) tickMarks(data []*owm.CurrentWeatherData) string { - str := "" - - if len(data) > 1 { - marks := strings.Repeat("*", len(data)) - marks = marks[:widget.Idx] + "_" + marks[widget.Idx+1:] - - str = "[lightblue]" + fmt.Sprintf(wtf.RightAlignFormat(widget.View), marks) + "[white]" - } - - return str -} - func (widget *Widget) title(cityData *owm.CurrentWeatherData) string { return fmt.Sprintf(" %s %s ", widget.icon(cityData), cityData.Name) } diff --git a/wtf/utils.go b/wtf/utils.go index 4a1f05da..4bb061f3 100644 --- a/wtf/utils.go +++ b/wtf/utils.go @@ -119,6 +119,20 @@ func RowColor(module string, idx int) string { } } +func SygilStr(len, pos int, view *tview.TextView) string { + sygils := "" + + if len > 0 { + sygils = strings.Repeat(Config.UString("wtf.paging.pageSygil", "*"), pos) + sygils = sygils + Config.UString("wtf.paging.selectedSygil", "_") + sygils = sygils + strings.Repeat(Config.UString("wtf.paging.pageSygil", "*"), len-1-pos) + + sygils = "[lightblue]" + fmt.Sprintf(RightAlignFormat(view), sygils) + "[white]" + } + + return sygils +} + /* -------------------- Slice Conversion -------------------- */ func ToInts(slice []interface{}) []int {