package tui

import (
	"log"

	"github.com/jroimartin/gocui"
)

var users []string
var prevWidth, prevHeight int
var chatData ChatData
var selectedUserIdx int = 0

func Run() {

	LoadContacts("configs/servers/default")

	g, err := gocui.NewGui(gocui.OutputNormal)
	if err != nil {
		log.Panicln(err)
	}
	defer g.Close()

	g.SetManagerFunc(layout)

	if err := keybindings(g); err != nil {
		log.Panicln(err)
	}

	if err := g.MainLoop(); err != nil && err != gocui.ErrQuit {
		log.Panicln(err)
	}
}
