summaryrefslogtreecommitdiff
path: root/client/main.go
diff options
context:
space:
mode:
authorcitrons <citrons@mondecitronne.com>2025-06-01 15:38:17 -0500
committercitrons <citrons@mondecitronne.com>2025-06-01 15:38:17 -0500
commite2dc5b6fbb6adf6f379ef0123c214a196211c305 (patch)
treecc976665dd2e0916af100b5c0f7f629cc1936b01 /client/main.go
parente740e5478a43358fbbd79636483d000e01f88b7e (diff)
joining channels
Diffstat (limited to 'client/main.go')
-rw-r--r--client/main.go23
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
+ }
}
}