diff options
Diffstat (limited to 'client/main.go')
| -rw-r--r-- | client/main.go | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/client/main.go b/client/main.go index 4c65752..a9929be 100644 --- a/client/main.go +++ b/client/main.go @@ -7,30 +7,41 @@ import ( "os" ) +var globalApp *application + func main() { err := tui.Start() if err != nil { fmt.Fprintln(os.Stderr, "error initializing terminal: ", err) + os.Exit(-1) } + defer func() { + tui.End() + fmt.Println("bye!") + }() - app := newApplication("localhost:27508") - go app.RunClient() + globalApp = newApplication("localhost:27508") + go globalApp.RunClient() + defer globalApp.Stop() drawTick := time.Tick(time.Second / 60) redraw := true for { select { - case m := <-app.Messages(): - m.Handle(app) + case m := <-globalApp.Messages(): + m.Handle(globalApp) redraw = true case e := <-tui.Events(): - app.onInput(e) + globalApp.onInput(e) redraw = true case <-drawTick: if redraw { - app.show() + globalApp.show() redraw = false } } + if globalApp.quit == true { + return + } } } |
