boltbrowser/screen.go

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