package main

import (
	"fmt"

	"github.com/br0xen/termbox-screen"
	termbox "github.com/nsf/termbox-go"
)

const (
	DefaultFg = termbox.ColorWhite
	DefaultBg = termbox.ColorBlack
	TitleFg   = termbox.ColorWhite
	TitleBg   = termbox.ColorBlue
	CursorFg  = termbox.ColorBlack
	CursorBg  = termbox.ColorGreen

	ScreenIdExit = iota - 1
	ScreenIdMain
	ScreenIdError
)

type AppState struct {
	ui *termboxScreen.Manager
}

func NewApp(parms []string) *AppState {
	return &AppState{}
}

func (a *AppState) run(parms []string) int {
	var err error
	a.ui = termboxScreen.NewManager()
	if err = a.ui.AddAndInitializeScreen(NewMainScreen()); err != nil {
		a.ui.Close()
		fmt.Println(err.Error())
		return 1
	}

	if err := a.ui.Loop(); err != nil {
		return 1
	}
	return 0
}
