From 3ea19ff21e5cda8afca7f8114e18466e9cf7663e Mon Sep 17 00:00:00 2001 From: Hubert Hirtz Date: Wed, 2 Sep 2020 00:06:37 +0200 Subject: Typing indicator timeout --- window.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'window.go') 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) +} -- cgit v1.2.3