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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
package main
import (
"sync"
log "github.com/Sirupsen/logrus"
)
// GRVStatusView manages the status bar view and help view displayed at the bottom of grv
type GRVStatusView struct {
statusBarView WindowView
helpBarView WindowView
statusBarWin *Window
helpBarWin *Window
active bool
lock sync.Mutex
}
// NewGRVStatusView creates a new instance
func NewGRVStatusView(helpRenderer HelpRenderer, repoData RepoData, channels Channels, config ConfigSetter) *GRVStatusView {
return &GRVStatusView{
statusBarView: NewStatusBarView(repoData, channels, config),
helpBarView: NewHelpBarView(helpRenderer),
statusBarWin: NewWindow("statusBarView", config),
helpBarWin: NewWindow("helpBarView", config),
}
}
// Initialise does nothing
func (grvStatusView *GRVStatusView) Initialise() (err error) {
return
}
// Dispose of any resources held by the view
func (grvStatusView *GRVStatusView) Dispose() {
}
// HandleEvent does nothing
func (grvStatusView *GRVStatusView) HandleEvent(event Event) (err error) {
if err = grvStatusView.statusBarView.HandleEvent(event); err != nil {
return
}
err = grvStatusView.helpBarView.HandleEvent(event)
return
}
// HandleAction passes on the action to its child views for them to habdle
func (grvStatusView *GRVStatusView) HandleAction(action Action) (err error) {
if err = grvStatusView.statusBarView.HandleAction(action); err != nil {
return
}
err = grvStatusView.helpBarView.HandleAction(action)
return
}
// OnActiveChange updates the active state of this view and its child views
func (grvStatusView *GRVStatusView) OnActiveChange(active bool) {
grvStatusView.lock.Lock()
defer grvStatusView.lock.Unlock()
log.Debugf("GRVStatusView active: %v", active)
grvStatusView.active = active
grvStatusView.statusBarView.OnActiveChange(active)
grvStatusView.helpBarView.OnActiveChange(active)
}
// ViewID returns the view ID of the status view
func (grvStatusView *GRVStatusView) ViewID() ViewID {
return ViewGRVStatus
}
// Render generates its child views and returns the windows that constitute the status view as a whole
func (grvStatusView *GRVStatusView) Render(viewDimension ViewDimension) (wins []*Window, err error) {
grvStatusView.lock.Lock()
defer grvStatusView.lock.Unlock()
viewDimension.rows--
grvStatusView.statusBarWin.Resize(viewDimension)
grvStatusView.helpBarWin.Resize(viewDimension)
grvStatusView.statusBarWin.Clear()
grvStatusView.helpBarWin.Clear()
if err = grvStatusView.statusBarView.Render(grvStatusView.statusBarWin); err != nil {
return
}
if err = grvStatusView.helpBarView.Render(grvStatusView.helpBarWin); err != nil {
return
}
grvStatusView.statusBarWin.SetPosition(0, 0)
grvStatusView.helpBarWin.SetPosition(1, 0)
wins = []*Window{grvStatusView.statusBarWin, grvStatusView.helpBarWin}
return
}
// RenderHelpBar does nothing
func (grvStatusView *GRVStatusView) RenderHelpBar(lineBuilder *LineBuilder) (err error) {
return grvStatusView.statusBarView.RenderHelpBar(lineBuilder)
}
// ActiveView returns the status bar view
// The help bar view is display only
func (grvStatusView *GRVStatusView) ActiveView() (childView BaseView) {
return grvStatusView.statusBarView
}
// Title returns the title of the status view
func (grvStatusView *GRVStatusView) Title() string {
return "Status View"
}
|