mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
WTF-400 Move settings-related functions from util.go into common_settings.go
This commit is contained in:
@@ -2,8 +2,6 @@ package gerrit
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/wtfutil/wtf/wtf"
|
||||
)
|
||||
|
||||
func (widget *Widget) display() {
|
||||
@@ -16,7 +14,8 @@ func (widget *Widget) display() {
|
||||
|
||||
widget.View.SetTitle(widget.ContextualTitle(fmt.Sprintf("%s- %s", widget.Name(), widget.title(project))))
|
||||
|
||||
str := wtf.SigilStr(len(widget.GerritProjects), widget.Idx, widget.View) + "\n"
|
||||
_, _, width, _ := widget.View.GetRect()
|
||||
str := widget.settings.common.SigilStr(len(widget.GerritProjects), widget.Idx, width) + "\n"
|
||||
str = str + " [red]Stats[white]\n"
|
||||
str = str + widget.displayStats(project)
|
||||
str = str + "\n"
|
||||
@@ -64,11 +63,12 @@ func (widget *Widget) displayStats(project *GerritProject) string {
|
||||
return str
|
||||
}
|
||||
|
||||
func (widget *Widget) rowColor(index int) string {
|
||||
if widget.View.HasFocus() && (index == widget.selected) {
|
||||
return wtf.DefaultFocussedRowColor()
|
||||
func (widget *Widget) rowColor(idx int) string {
|
||||
if widget.View.HasFocus() && (idx == widget.selected) {
|
||||
widget.settings.common.DefaultFocussedRowColor()
|
||||
}
|
||||
return wtf.RowColor("gerrit", index)
|
||||
|
||||
return widget.settings.common.RowColor(idx)
|
||||
}
|
||||
|
||||
func (widget *Widget) title(project *GerritProject) string {
|
||||
|
||||
@@ -4,8 +4,6 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"unicode/utf8"
|
||||
|
||||
"github.com/wtfutil/wtf/wtf"
|
||||
)
|
||||
|
||||
func (widget *Widget) display() {
|
||||
@@ -18,7 +16,8 @@ func (widget *Widget) display() {
|
||||
title := fmt.Sprintf("%s - [green]%s[white]", widget.Name(), repoData.Repository)
|
||||
widget.View.SetTitle(widget.ContextualTitle(title))
|
||||
|
||||
str := wtf.SigilStr(len(widget.GitRepos), widget.Idx, widget.View) + "\n"
|
||||
_, _, width, _ := widget.View.GetRect()
|
||||
str := widget.settings.common.SigilStr(len(widget.GitRepos), widget.Idx, width) + "\n"
|
||||
str = str + " [red]Branch[white]\n"
|
||||
str = str + fmt.Sprintf(" %s", repoData.Branch)
|
||||
str = str + "\n"
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/google/go-github/github"
|
||||
"github.com/wtfutil/wtf/wtf"
|
||||
)
|
||||
|
||||
func (widget *Widget) display() {
|
||||
@@ -16,7 +15,8 @@ func (widget *Widget) display() {
|
||||
|
||||
widget.View.SetTitle(widget.ContextualTitle(fmt.Sprintf("%s - %s", widget.Name(), widget.title(repo))))
|
||||
|
||||
str := wtf.SigilStr(len(widget.GithubRepos), widget.Idx, widget.View) + "\n"
|
||||
_, _, width, _ := widget.View.GetRect()
|
||||
str := widget.settings.common.SigilStr(len(widget.GithubRepos), widget.Idx, width) + "\n"
|
||||
str = str + " [red]Stats[white]\n"
|
||||
str = str + widget.displayStats(repo)
|
||||
str = str + "\n"
|
||||
|
||||
@@ -2,8 +2,6 @@ package gitlab
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/wtfutil/wtf/wtf"
|
||||
)
|
||||
|
||||
func (widget *Widget) display() {
|
||||
@@ -16,7 +14,8 @@ func (widget *Widget) display() {
|
||||
|
||||
widget.View.SetTitle(fmt.Sprintf("%s- %s", widget.Name(), widget.title(project)))
|
||||
|
||||
str := wtf.SigilStr(len(widget.GitlabProjects), widget.Idx, widget.View) + "\n"
|
||||
_, _, width, _ := widget.View.GetRect()
|
||||
str := widget.settings.common.SigilStr(len(widget.GitlabProjects), widget.Idx, width) + "\n"
|
||||
str = str + " [red]Stats[white]\n"
|
||||
str = str + widget.displayStats(project)
|
||||
str = str + "\n"
|
||||
|
||||
@@ -116,10 +116,10 @@ func (widget *Widget) contentFrom(messages []Message) string {
|
||||
|
||||
func (widget *Widget) rowColor(idx int) string {
|
||||
if widget.View.HasFocus() && (idx == widget.selected) {
|
||||
return wtf.DefaultFocussedRowColor()
|
||||
widget.settings.common.DefaultFocussedRowColor()
|
||||
}
|
||||
|
||||
return wtf.RowColor("gitter", idx)
|
||||
return widget.settings.common.RowColor(idx)
|
||||
}
|
||||
|
||||
func (widget *Widget) next() {
|
||||
|
||||
@@ -123,10 +123,10 @@ func (widget *Widget) contentFrom(stories []Story) string {
|
||||
|
||||
func (widget *Widget) rowColor(idx int) string {
|
||||
if widget.View.HasFocus() && (idx == widget.selected) {
|
||||
return wtf.DefaultFocussedRowColor()
|
||||
widget.settings.common.DefaultFocussedRowColor()
|
||||
}
|
||||
|
||||
return wtf.RowColor("hackernews", idx)
|
||||
return widget.settings.common.RowColor(idx)
|
||||
}
|
||||
|
||||
func (widget *Widget) next() {
|
||||
|
||||
@@ -112,10 +112,10 @@ func (widget *Widget) contentFrom(view *View) string {
|
||||
|
||||
func (widget *Widget) rowColor(idx int) string {
|
||||
if widget.View.HasFocus() && (idx == widget.selected) {
|
||||
return wtf.DefaultFocussedRowColor()
|
||||
widget.settings.common.DefaultFocussedRowColor()
|
||||
}
|
||||
|
||||
return wtf.DefaultRowColor()
|
||||
return widget.settings.common.RowColor(idx)
|
||||
}
|
||||
|
||||
func (widget *Widget) jobColor(job *Job) string {
|
||||
|
||||
@@ -138,14 +138,10 @@ func (widget *Widget) contentFrom(searchResult *SearchResult) string {
|
||||
|
||||
func (widget *Widget) rowColor(idx int) string {
|
||||
if widget.View.HasFocus() && (idx == widget.selected) {
|
||||
return wtf.DefaultFocussedRowColor()
|
||||
widget.settings.common.DefaultFocussedRowColor()
|
||||
}
|
||||
|
||||
if idx%2 == 0 {
|
||||
return widget.settings.colors.rows.even
|
||||
}
|
||||
|
||||
return widget.settings.colors.rows.odd
|
||||
return widget.settings.common.RowColor(idx)
|
||||
}
|
||||
|
||||
func (widget *Widget) issueTypeColor(issue *Issue) string {
|
||||
|
||||
@@ -4,8 +4,6 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"unicode/utf8"
|
||||
|
||||
"github.com/wtfutil/wtf/wtf"
|
||||
)
|
||||
|
||||
func (widget *Widget) display() {
|
||||
@@ -18,7 +16,8 @@ func (widget *Widget) display() {
|
||||
title := fmt.Sprintf("%s - [green]%s[white]", widget.Name(), repoData.Repository)
|
||||
widget.View.SetTitle(widget.ContextualTitle(title))
|
||||
|
||||
str := wtf.SigilStr(len(widget.Data), widget.Idx, widget.View) + "\n"
|
||||
_, _, width, _ := widget.View.GetRect()
|
||||
str := widget.settings.common.SigilStr(len(widget.Data), widget.Idx, width) + "\n"
|
||||
str = str + " [red]Branch:Bookmark[white]\n"
|
||||
str = str + fmt.Sprintf(" %s:%s\n", repoData.Branch, repoData.Bookmark)
|
||||
str = str + "\n"
|
||||
|
||||
@@ -110,9 +110,10 @@ func (widget *Widget) contentFrom(result *Result) string {
|
||||
|
||||
func (widget *Widget) rowColor(idx int) string {
|
||||
if widget.View.HasFocus() && (idx == widget.selected) {
|
||||
return wtf.DefaultFocussedRowColor()
|
||||
widget.settings.common.DefaultFocussedRowColor()
|
||||
}
|
||||
return "white"
|
||||
|
||||
return widget.settings.common.RowColor(idx)
|
||||
}
|
||||
|
||||
func statusColor(item *Item) string {
|
||||
|
||||
@@ -76,7 +76,8 @@ func (widget *Widget) display() {
|
||||
title := fmt.Sprintf("[green]%s[white]", widget.CurrentSource())
|
||||
title = widget.ContextualTitle(title)
|
||||
|
||||
text := wtf.SigilStr(len(widget.Sources), widget.Idx, widget.View) + "\n"
|
||||
_, _, width, _ := widget.View.GetRect()
|
||||
text := widget.settings.common.SigilStr(len(widget.Sources), widget.Idx, width) + "\n"
|
||||
|
||||
if widget.settings.format {
|
||||
text = text + widget.formattedText()
|
||||
|
||||
@@ -14,8 +14,8 @@ const checkWidth = 4
|
||||
func (widget *Widget) display() {
|
||||
str := ""
|
||||
newList := checklist.NewChecklist(
|
||||
widget.settings.common.Sigils.CheckedIcon,
|
||||
widget.settings.common.Sigils.UncheckedIcon,
|
||||
widget.settings.common.Sigils.Checkbox.Checked,
|
||||
widget.settings.common.Sigils.Checkbox.Unchecked,
|
||||
)
|
||||
|
||||
offset := 0
|
||||
|
||||
@@ -54,7 +54,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
||||
app: app,
|
||||
settings: settings,
|
||||
filePath: settings.filePath,
|
||||
list: checklist.NewChecklist(settings.common.Sigils.CheckedIcon, settings.common.Sigils.UncheckedIcon),
|
||||
list: checklist.NewChecklist(settings.common.Sigils.Checkbox.Checked, settings.common.Sigils.Checkbox.Unchecked),
|
||||
pages: pages,
|
||||
}
|
||||
|
||||
@@ -234,8 +234,8 @@ func (widget *Widget) persist() {
|
||||
// items have the correct checked/unchecked icon per the user's preferences
|
||||
func (widget *Widget) setItemChecks() {
|
||||
for _, item := range widget.list.Items {
|
||||
item.CheckedIcon = widget.settings.common.CheckedIcon
|
||||
item.UncheckedIcon = widget.settings.common.UncheckedIcon
|
||||
item.CheckedIcon = widget.settings.common.Checkbox.Checked
|
||||
item.UncheckedIcon = widget.settings.common.Checkbox.Unchecked
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,8 @@ func (widget *Widget) display() {
|
||||
title := fmt.Sprintf("[green]%s[white]", proj.Project.Name)
|
||||
widget.View.SetTitle(widget.ContextualTitle(title))
|
||||
|
||||
str := wtf.SigilStr(len(widget.projects), widget.idx, widget.View) + "\n"
|
||||
_, _, width, _ := widget.View.GetRect()
|
||||
str := widget.settings.common.SigilStr(len(widget.projects), widget.idx, width) + "\n"
|
||||
|
||||
maxLen := proj.LongestLine()
|
||||
|
||||
|
||||
@@ -102,9 +102,10 @@ func (widget *Widget) contentFrom(builds *Builds) string {
|
||||
|
||||
func (widget *Widget) rowColor(idx int) string {
|
||||
if widget.View.HasFocus() && (idx == widget.selected) {
|
||||
return wtf.DefaultFocussedRowColor()
|
||||
widget.settings.common.DefaultFocussedRowColor()
|
||||
}
|
||||
return "White"
|
||||
|
||||
return widget.settings.common.RowColor(idx)
|
||||
}
|
||||
|
||||
func buildColor(build *Build) string {
|
||||
|
||||
@@ -79,7 +79,8 @@ func (widget *Widget) display() {
|
||||
return
|
||||
}
|
||||
|
||||
str := wtf.SigilStr(len(widget.Sources), widget.Idx, widget.View) + "\n"
|
||||
_, _, width, _ := widget.View.GetRect()
|
||||
str := widget.settings.common.SigilStr(len(widget.Sources), widget.Idx, width) + "\n"
|
||||
for _, tweet := range tweets {
|
||||
str = str + widget.format(tweet)
|
||||
}
|
||||
|
||||
@@ -27,7 +27,8 @@ func (widget *Widget) display() {
|
||||
|
||||
widget.View.SetTitle(widget.title(cityData))
|
||||
|
||||
content := wtf.SigilStr(len(widget.Data), widget.Idx, widget.View) + "\n"
|
||||
_, _, width, _ := widget.View.GetRect()
|
||||
content := widget.settings.common.SigilStr(len(widget.Data), widget.Idx, width) + "\n"
|
||||
content = content + widget.description(cityData) + "\n\n"
|
||||
content = content + widget.temperatures(cityData) + "\n"
|
||||
content = content + widget.sunInfo(cityData)
|
||||
|
||||
Reference in New Issue
Block a user