-
Notifications
You must be signed in to change notification settings - Fork 91
/
screen.go
47 lines (39 loc) · 1010 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
43
44
45
46
47
package main
import "github.com/nsf/termbox-go"
// Screen is a basic structure for all of the applications screens
type Screen interface {
handleKeyEvent(event termbox.Event) int
performLayout()
drawScreen(style Style)
}
const (
// BrowserScreenIndex is the index
BrowserScreenIndex = iota
// AboutScreenIndex The idx number for the 'About' Screen
AboutScreenIndex
// ExitScreenIndex The idx number for Exiting
ExitScreenIndex
)
func defaultScreensForData(db *BoltDB) []Screen {
browserScreen := BrowserScreen{db: db, rightViewPort: ViewPort{}, leftViewPort: ViewPort{}}
aboutScreen := AboutScreen(0)
screens := [...]Screen{
&browserScreen,
&aboutScreen,
}
return screens[:]
}
func drawBackground(bg termbox.Attribute) {
termbox.Clear(0, bg)
}
func layoutAndDrawScreen(screen Screen, style Style) {
screen.performLayout()
drawBackground(style.defaultBg)
screen.drawScreen(style)
termbox.Flush()
}
type Line struct {
Text string
Fg termbox.Attribute
Bg termbox.Attribute
}