gask-old/screen.go

74 lines
1.3 KiB
Go
Raw Normal View History

2019-02-15 17:15:26 +00:00
package main
import (
2019-02-26 19:22:37 +00:00
"time"
2019-02-15 17:15:26 +00:00
termbox "github.com/nsf/termbox-go"
)
type Screen interface {
handleKeyEvent(termbox.Event) int
initialize(Bundle) error
drawScreen()
}
const (
ScreenMain = iota
ScreenTask
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{}
2019-02-15 17:15:26 +00:00
aboutScreen := AboutScreen{}
taskScreen := TaskScreen{}
2019-02-15 17:15:26 +00:00
a.screens = append(a.screens, &mainScreen)
a.screens = append(a.screens, &taskScreen)
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()
}
}
2019-02-26 19:22:37 +00:00
func checkForUpdate(e chan termbox.Event) {
for {
time.Sleep(time.Minute)
if app.diskListChanged() {
e <- termbox.Event{
Type: termbox.EventError,
Err: app.e(ResStrListChanged),
}
}
2019-02-26 19:22:37 +00:00
}
}
/*
* ViewPort helps keep track of what's being displayed on the screen
*/
type ViewPort struct {
bytesPerRow int
numberOfRows int
firstRow int
}