-
Notifications
You must be signed in to change notification settings - Fork 34
/
screen.go
42 lines (34 loc) · 829 Bytes
/
screen.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
package main
import "github.com/nsf/termbox-go"
type Screen interface {
receiveEvents(input <-chan termbox.Event, output chan<- interface{}, quit <-chan bool)
performLayout()
drawScreen(style Style)
}
const (
ABOUT_SCREEN_INDEX = iota
PALETTE_SCREEN_INDEX
DATA_SCREEN_INDEX
EXIT_SCREEN_INDEX
)
func defaultScreensForFiles(files []FileInfo) []Screen {
data_screen := DataScreen{}
data_screen.initializeWithFiles(files)
about_screen := AboutScreen{}
palette_screen := PaletteScreen(0)
screens := [...]Screen{
&about_screen,
&palette_screen,
&data_screen,
}
return screens[:]
}
func drawBackground(bg termbox.Attribute) {
termbox.Clear(0, bg)
}
func layoutAndDrawScreen(screen Screen, style Style) {
screen.performLayout()
drawBackground(style.default_bg)
screen.drawScreen(style)
termbox.Flush()
}