32 lines
740 B
Go
32 lines
740 B
Go
package main
|
|
|
|
import "github.com/nsf/termbox-go"
|
|
|
|
// Screen is a basic structure for all of the applications screens
|
|
type Screen interface {
|
|
handleEvent(event termbox.Event) int
|
|
performLayout(style Style)
|
|
drawScreen(style Style)
|
|
}
|
|
|
|
func drawBackground(bg termbox.Attribute) {
|
|
termbox.Clear(0, bg)
|
|
}
|
|
|
|
func layoutAndDrawScreen(screen Screen, style Style) {
|
|
screen.performLayout(style)
|
|
drawBackground(style.defaultBg)
|
|
screen.drawScreen(style)
|
|
termbox.Flush()
|
|
}
|
|
|
|
// Style holds a bunch of termbox attributes to help keep a consistent theme
|
|
type Style struct {
|
|
defaultBg termbox.Attribute
|
|
defaultFg termbox.Attribute
|
|
titleFg termbox.Attribute
|
|
titleBg termbox.Attribute
|
|
cursorFg termbox.Attribute
|
|
cursorBg termbox.Attribute
|
|
}
|