summaryrefslogtreecommitdiff
path: root/window.go
diff options
context:
space:
mode:
authorHubert Hirtz <hubert@hirtzfr.eu>2020-09-02 00:06:37 +0200
committerHubert Hirtz <hubert@hirtzfr.eu>2020-09-02 16:00:57 +0200
commit3ea19ff21e5cda8afca7f8114e18466e9cf7663e (patch)
tree833a97485ebd98a2d1fd805db6f3eeacaf30127a /window.go
parentirc: Reset typing ratelimiter after sent message (diff)
Typing indicator timeout
Diffstat (limited to 'window.go')
-rw-r--r--window.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/window.go b/window.go
index a3b7e91..dcd3fba 100644
--- a/window.go
+++ b/window.go
@@ -2,6 +2,7 @@ package senpai
import (
"math/rand"
+ "strings"
"time"
"git.sr.ht/~taiite/senpai/ui"
@@ -36,5 +37,26 @@ func (app *App) addLineNow(buffer string, line ui.Line) {
}
func (app *App) draw() {
+ if app.s != nil {
+ app.setStatus()
+ }
app.win.Draw()
}
+
+func (app *App) setStatus() {
+ ts := app.s.Typings(app.win.CurrentBuffer())
+ status := ""
+ if 3 < len(ts) {
+ status = "several people are typing..."
+ } else {
+ verb := " is typing..."
+ if 1 < len(ts) {
+ verb = " are typing..."
+ status = strings.Join(ts[:len(ts)-1], ", ") + " and "
+ }
+ if 0 < len(ts) {
+ status += ts[len(ts)-1] + verb
+ }
+ }
+ app.win.SetStatus(status)
+}