boltbrowser/screen.go
2015-04-30 11:22:37 -05:00

41 lines
758 B
Go

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 {
var view_port ViewPort
var cursor Cursor
browser_screen := BrowserScreen{db: db, cursor: cursor, view_port: view_port}
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()
}