-
Notifications
You must be signed in to change notification settings - Fork 0
/
view.go
76 lines (66 loc) · 1.85 KB
/
view.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package ui
import (
"fmt"
"github.com/charmbracelet/lipgloss"
)
func (m model) View() string {
var content string
var footer string
var statusBar string
if m.revStartChosen && !m.revEndChosen {
statusBar += "picking revision range: " + revChoiceStyle.Render(fmt.Sprintf("%s..?", m.revStart))
} else if m.revEndChosen {
statusBar += "revision range picked: " + revChoiceStyle.Render(fmt.Sprintf("%s..%s", m.revStart, m.revEnd))
}
if m.message != "" {
statusBar += RightPadTrim(m.message, m.terminalWidth)
}
switch m.activePane {
case commitsList:
content = m.commitListStyle.Render(m.commitsList.View())
case commitDetails:
var commitStatsVP string
if !m.commitStatsVPReady {
commitStatsVP = "\n Initializing..."
} else {
commitStatsVP = viewPortStyle.Render(fmt.Sprintf(" %s\n\n%s\n",
commitStatsTitleStyle.Render("Commit Details"),
commitDetailsStyle.Render(m.commitDetailsVP.View())))
}
content = commitStatsVP
case branchList:
content = m.commitListStyle.Render(m.branchList.View())
case helpView:
var helpVP string
if !m.helpVPReady {
helpVP = "\n Initializing..."
} else {
helpVP = viewPortStyle.Render(fmt.Sprintf(" %s\n\n%s\n",
helpVPTitleStyle.Render("Help"),
m.helpVP.View()))
}
content = helpVP
}
footerStyle := lipgloss.NewStyle().
Foreground(lipgloss.Color("#282828")).
Background(lipgloss.Color("#7c6f64"))
var headRef string
if m.currentRef != nil {
headRef = fmt.Sprintf(" %s -> %s", headRefStyle.Render("HEAD"), headRefStyle.Render(m.currentRef.Name().Short()))
}
var helpMsg string
if m.showHelp {
helpMsg = " " + helpMsgStyle.Render("press ? for help")
}
footerStr := fmt.Sprintf("%s%s%s",
modeStyle.Render("commits"),
headRef,
helpMsg,
)
footer = footerStyle.Render(footerStr)
return lipgloss.JoinVertical(lipgloss.Left,
content,
statusBar,
footer,
)
}