diff options
author | Hubert Hirtz <hubert@hirtzfr.eu> | 2020-09-02 00:06:37 +0200 |
---|---|---|
committer | Hubert Hirtz <hubert@hirtzfr.eu> | 2020-09-02 16:00:57 +0200 |
commit | 3ea19ff21e5cda8afca7f8114e18466e9cf7663e (patch) | |
tree | 833a97485ebd98a2d1fd805db6f3eeacaf30127a /window.go | |
parent | irc: Reset typing ratelimiter after sent message (diff) |
Typing indicator timeout
Diffstat (limited to 'window.go')
-rw-r--r-- | window.go | 22 |
1 files changed, 22 insertions, 0 deletions
@@ -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) +} |