boltbrowser/screen.go

40 lines
723 B
Go
Raw Normal View History

2015-04-24 22:53:33 +00:00
package main
import "github.com/nsf/termbox-go"
type Screen interface {
handleKeyEvent(event termbox.Event) int
performLayout()
drawScreen(style Style)
}
const (
BROWSER_SCREEN_INDEX = iota
ABOUT_SCREEN_INDEX
EXIT_SCREEN_INDEX
)
func defaultScreensForData(db *BoltDB) []Screen {
2015-04-24 22:53:33 +00:00
var view_port ViewPort
2015-05-20 13:56:41 +00:00
browser_screen := BrowserScreen{db: db, view_port: view_port}
2015-04-24 22:53:33 +00:00
about_screen := AboutScreen(0)
screens := [...]Screen{
&browser_screen,
&about_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()
}