1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

Row color as common function

This commit is contained in:
Chris Cummer 2018-05-14 20:45:18 -07:00
parent 0d3b663642
commit 0ff65bbd5c
3 changed files with 13 additions and 22 deletions

View File

@ -16,7 +16,7 @@ func (widget *Widget) display(clocks []Clock) {
for idx, clock := range clocks {
str = str + fmt.Sprintf(
" [%s]%-12s %-10s %7s[white]\n",
widget.rowColor(idx),
wtf.RowColor("clocks", idx),
clock.Label,
clock.LocalTime.Format(wtf.SimpleTimeFormat),
clock.LocalTime.Format(wtf.SimpleDateFormat),
@ -25,13 +25,3 @@ func (widget *Widget) display(clocks []Clock) {
fmt.Fprintf(widget.View, "%s", str)
}
func (widget *Widget) rowColor(idx int) string {
rowCol := Config.UString("wtf.mods.clocks.colors.row.even", "lightblue")
if idx%2 == 0 {
rowCol = Config.UString("wtf.mods.clocks.colors.row.odd", "white")
}
return rowCol
}

View File

@ -64,7 +64,7 @@ func (widget *Widget) contentFrom(searchResult *SearchResult) string {
widget.issueTypeColor(&issue),
issue.IssueFields.IssueType.Name,
issue.Key,
widget.rowColor(idx),
wtf.RowColor("jira", idx),
issue.IssueFields.Summary,
)
}
@ -88,13 +88,3 @@ func (widget *Widget) issueTypeColor(issue *Issue) string {
return color
}
func (widget *Widget) rowColor(idx int) string {
rowCol := Config.UString("wtf.mods.jira.colors.row.even", "lightblue")
if idx%2 == 0 {
rowCol = Config.UString("wtf.mods.jira.colors.row.odd", "white")
}
return rowCol
}

View File

@ -103,6 +103,17 @@ func RightAlignFormat(view *tview.TextView) string {
return fmt.Sprintf("%%%ds", w-1)
}
func RowColor(module string, idx int) string {
evenKey := fmt.Sprintf("wtf.mods.%s.colors.row.even", module)
oddKey := fmt.Sprintf("wtf.mods.%s.colors.row.odd", module)
if idx%2 == 0 {
return Config.UString(evenKey, "white")
} else {
return Config.UString(oddKey, "lightblue")
}
}
/* -------------------- Slice Conversion -------------------- */
func ToInts(slice []interface{}) []int {