Skip to content

Commit bd7482a

Browse files
committed
remove global vars from renderer
1 parent 59f1ebd commit bd7482a

File tree

1 file changed

+17
-19
lines changed

1 file changed

+17
-19
lines changed

gui/text-renderer.go

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,39 +23,37 @@ var (
2323
white = color.New(color.FgWhite)
2424
magenta = color.New(color.FgMagenta)
2525

26+
keySymbol = " " + yellow.Sprint("🔑") + ws
27+
sep = " " + yellow.Sprint("|") + ws
28+
29+
pushable = string(blue.Sprint("↖"))
30+
pullable = string(blue.Sprint("↘"))
31+
dirty = string(yellow.Sprint("✗"))
32+
2633
bold = color.New(color.Bold)
34+
)
2735

36+
const (
2837
maxBranchLength = 15
2938
maxRepositoryLength = 20
3039
hashLength = 7
3140

32-
ws = " "
33-
pushable = string(blue.Sprint("↖"))
34-
pullable = string(blue.Sprint("↘"))
35-
dirty = string(yellow.Sprint("✗"))
36-
41+
ws = " "
3742
queuedSymbol = "•"
3843
workingSymbol = "•"
3944
successSymbol = "✔"
4045
pauseSymbol = "॥"
4146
failSymbol = "✗"
4247

43-
fetchSymbol = "↓"
44-
pullSymbol = "↓↳"
45-
mergeSymbol = "↳"
46-
checkoutSymbol = "↱"
47-
48-
keySymbol = ws + yellow.Sprint("🔑") + ws
49-
50-
sep = ws + yellow.Sprint("|") + ws
51-
48+
fetchSymbol = "↓"
49+
pullSymbol = "↓↳"
50+
mergeSymbol = "↳"
51+
checkoutSymbol = "↱"
5252
modeSeperator = ""
5353
keyBindingSeperator = "░"
5454

5555
selectionIndicator = "→" + ws
5656
tab = ws
57-
58-
renderRules = &RepositoryDecorationRules{}
5957
)
6058

6159
// RepositoryDecorationRules is a rule set for creating repositry labels
@@ -70,7 +68,7 @@ type RepositoryDecorationRules struct {
7068
// this function handles the render and representation of the repository
7169
// TODO: cleanup is required, right now it looks too complicated
7270
func (gui *Gui) repositoryLabel(r *git.Repository) string {
73-
renderRules = gui.renderRules()
71+
renderRules := gui.renderRules()
7472

7573
gui.renderTableHeader(renderRules)
7674

@@ -151,8 +149,8 @@ func (gui *Gui) renderTableHeader(rule *RepositoryDecorationRules) {
151149
var header string
152150
revlen := 2 + rule.MaxPullables + 2 + rule.MaxPushables + 1
153151
header = ws + magenta.Sprint(align("revs", revlen, true, true)) + sep
154-
header = header + align(magenta.Sprint("branch"), renderRules.MaxBranch, true, true) + sep
155-
header = header + magenta.Sprint(align("name", renderRules.MaxName+2, true, true)) + sep
152+
header = header + align(magenta.Sprint("branch"), rule.MaxBranch, true, true) + sep
153+
header = header + magenta.Sprint(align("name", rule.MaxName+2, true, true)) + sep
156154
fmt.Fprintln(v, header)
157155
}
158156

0 commit comments

Comments
 (0)