2016-05-05 20:59:09 +00:00
|
|
|
package main
|
|
|
|
|
2016-06-27 12:23:56 +00:00
|
|
|
// Windows doesn't support process backgrounding like *nix.
|
|
|
|
// So we have a separate loop for it.
|
|
|
|
|
2016-05-05 20:59:09 +00:00
|
|
|
import "github.com/nsf/termbox-go"
|
|
|
|
|
|
|
|
func mainLoop(memBolt *BoltDB, style Style) {
|
|
|
|
screens := defaultScreensForData(memBolt)
|
|
|
|
displayScreen := screens[BrowserScreenIndex]
|
|
|
|
layoutAndDrawScreen(displayScreen, style)
|
|
|
|
for {
|
|
|
|
event := termbox.PollEvent()
|
|
|
|
if event.Type == termbox.EventKey {
|
|
|
|
newScreenIndex := displayScreen.handleKeyEvent(event)
|
|
|
|
if newScreenIndex < len(screens) {
|
|
|
|
displayScreen = screens[newScreenIndex]
|
|
|
|
layoutAndDrawScreen(displayScreen, style)
|
|
|
|
} else {
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if event.Type == termbox.EventResize {
|
|
|
|
layoutAndDrawScreen(displayScreen, style)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|