package main import ( "errors" "time" termbox "github.com/nsf/termbox-go" ) type Screen interface { handleKeyEvent(termbox.Event) int initialize(Bundle) error drawScreen() } const ( ScreenMain = iota ScreenAbout ScreenExit DefaultBg = termbox.ColorBlack DefaultFg = termbox.ColorWhite TitleFg = termbox.ColorWhite TitleBg = termbox.ColorBlue CursorFg = termbox.ColorBlack CursorBg = termbox.ColorGreen ) func (a *AppState) BuildScreens() { mainScreen := MainScreen{} aboutScreen := AboutScreen{} a.screens = append(a.screens, &mainScreen) a.screens = append(a.screens, &aboutScreen) } func (a *AppState) drawBackground(bg termbox.Attribute) { termbox.Clear(0, bg) } func (a *AppState) layoutAndDrawScreen(s Screen) { a.drawBackground(DefaultBg) s.drawScreen() termbox.Flush() } func readUserInput(e chan termbox.Event) { for { e <- termbox.PollEvent() } } func checkForUpdate(e chan termbox.Event) { for { time.Sleep(time.Minute) // Check if the on-disk tasklist has changed //app.LoadTasklist() //app.LoadDoneList() if false { e <- termbox.Event{ Type: termbox.EventError, Err: errors.New("List changed elsewhere"), } } } } /* * ViewPort helps keep track of what's being displayed on the screen */ type ViewPort struct { bytesPerRow int numberOfRows int firstRow int }