summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app.go10
1 files changed, 8 insertions, 2 deletions
diff --git a/app.go b/app.go
index c44dc05..db5c776 100644
--- a/app.go
+++ b/app.go
@@ -192,7 +192,9 @@ func (app *App) eventLoop() {
if ev.content == nil {
return
}
- app.handleUIEvent(ev.content)
+ if !app.handleUIEvent(ev.content) {
+ return
+ }
} else {
app.handleIRCEvent(ev.src, ev.content)
}
@@ -359,7 +361,7 @@ func (app *App) uiLoop() {
}
}
-func (app *App) handleUIEvent(ev interface{}) {
+func (app *App) handleUIEvent(ev interface{}) bool {
switch ev := ev.(type) {
case *tcell.EventResize:
app.win.Resize()
@@ -369,11 +371,15 @@ func (app *App) handleUIEvent(ev interface{}) {
app.handleMouseEvent(ev)
case *tcell.EventKey:
app.handleKeyEvent(ev)
+ case *tcell.EventError:
+ // happens when the terminal is closing: in which case, exit
+ return false
case statusLine:
app.addStatusLine(ev.netID, ev.line)
default:
panic("unreachable")
}
+ return true
}
func (app *App) handleMouseEvent(ev *tcell.EventMouse) {