Use termbox-screen library

This commit is contained in:
2019-02-28 07:44:03 -06:00
parent 1c290b6b0b
commit 5d95e080ef
8 changed files with 122 additions and 226 deletions
+33 -2
View File
@@ -6,7 +6,9 @@ import (
"strings"
todotxt "github.com/br0xen/go-todotxt"
"github.com/br0xen/termbox-screen"
"github.com/br0xen/user-config"
termbox "github.com/nsf/termbox-go"
)
type AppState struct {
@@ -28,11 +30,22 @@ type AppState struct {
taskListLoaded bool
doneListLoaded bool
screens []Screen
uiManager *termboxScreen.Manager
lang *Translator
}
const (
DefaultFg = termbox.ColorWhite
DefaultBg = termbox.ColorBlack
TitleFg = termbox.ColorWhite
TitleBg = termbox.ColorBlue
CursorFg = termbox.ColorBlack
CursorBg = termbox.ColorGreen
ExitScreenId = -1
)
func NewApp() *AppState {
app := &AppState{Name: AppName, Version: AppVersion}
app.initialize()
@@ -49,7 +62,25 @@ func (a *AppState) run(parms []string) int {
if len(parms) == 0 || parms[0] == "ui" {
// UI Mode
a.mode = ResModeUI
return uiLoop()
a.uiManager = termboxScreen.NewManager()
a.uiManager.AddScreen(&MainScreen{})
a.uiManager.AddScreen(&TaskScreen{})
a.uiManager.AddScreen(&AboutScreen{})
for k := range a.uiManager.GetScreens() {
fmt.Print("Screen:", k, "\n")
}
a.uiManager.SetDisplayScreen(MainScreenId)
mainBundle := termboxScreen.Bundle{}
mainBundle.SetValue(MainBundleListKey, MainBundleListTodo)
if err := a.uiManager.InitializeScreen(MainScreenId, mainBundle); err != nil {
return 1
}
if err := a.uiManager.Loop(); err != nil {
return 1
}
return 0
}
a.mode = ResModeCLI
if fn, ok := a.OpFuncs[parms[0]]; ok {