-
Notifications
You must be signed in to change notification settings - Fork 288
/
components.go
55 lines (45 loc) · 887 Bytes
/
components.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
package hud
import (
"github.com/windmilleng/tilt/internal/hud/view"
"github.com/windmilleng/tilt/internal/rty"
)
const resourcesScollerName = "resources"
const alertScrollerName = "alert"
func (h *Hud) activeScroller() scroller {
am := h.activeModal()
if am != nil {
return am
} else {
return h.r.rty.ElementScroller(resourcesScollerName)
}
}
func (h *Hud) activeModal() modal {
if h.currentViewState.AlertMessage != "" {
return makeAlertModal(h.r.rty)
} else {
return nil
}
}
type scroller interface {
Up()
Down()
Top()
Bottom()
}
type modal interface {
Up()
Down()
Top()
Bottom()
Close(vs *view.ViewState)
}
type alertModal struct {
rty.TextScroller
}
var _ modal = alertModal{}
func makeAlertModal(r rty.RTY) modal {
return alertModal{r.TextScroller(alertScrollerName)}
}
func (am alertModal) Close(vs *view.ViewState) {
vs.AlertMessage = ""
}