From 9fb4378753ddec61a504a0dec403f40d6def7e90 Mon Sep 17 00:00:00 2001 From: Hubert Hirtz Date: Wed, 20 Oct 2021 17:33:10 +0200 Subject: Support for soju.im/bouncer-networks This patch also disable the highlight on reconnect. This might be an issue (the user would want to know when senpai is online again?), but with multiple connections, it's bothersome to have to unread all of them on start (it wasn't a problem with only one connection since it was read instantly). Now, lastbuffer.txt also contains the network ID, otherwise the user might end up on another buffer with the same name. This patch does not extend /r to support multiple networks (it will send the message to the latest query, whatever the current displayed network is). --- window.go | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) (limited to 'window.go') diff --git a/window.go b/window.go index ce416ed..82941a1 100644 --- a/window.go +++ b/window.go @@ -9,42 +9,50 @@ import ( "github.com/gdamore/tcell/v2" ) -var Home = "home" - const welcomeMessage = "senpai dev build. See senpai(1) for a list of keybindings and commands. Private messages and status notices go here." func (app *App) initWindow() { - app.win.AddBuffer(Home) - app.win.AddLine(Home, ui.NotifyNone, ui.Line{ + app.win.AddBuffer("", "(home)", "") + app.win.AddLine("", "", ui.NotifyNone, ui.Line{ Head: "--", Body: ui.PlainString(welcomeMessage), At: time.Now(), }) } -func (app *App) queueStatusLine(line ui.Line) { +type statusLine struct { + netID string + line ui.Line +} + +func (app *App) queueStatusLine(netID string, line ui.Line) { if line.At.IsZero() { line.At = time.Now() } app.events <- event{ - src: uiEvent, - content: line, + src: "*", + content: statusLine{ + netID: netID, + line: line, + }, } } -func (app *App) addStatusLine(line ui.Line) { - buffer := app.win.CurrentBuffer() - if buffer != Home { - app.win.AddLine(Home, ui.NotifyNone, line) +func (app *App) addStatusLine(netID string, line ui.Line) { + currentNetID, buffer := app.win.CurrentBuffer() + if currentNetID == netID && buffer != "" { + app.win.AddLine(netID, buffer, ui.NotifyNone, line) } - app.win.AddLine(buffer, ui.NotifyNone, line) + app.win.AddLine(netID, "", ui.NotifyNone, line) } func (app *App) setStatus() { - if app.s == nil { + netID, buffer := app.win.CurrentBuffer() + s := app.sessions[netID] + if s == nil { return } - ts := app.s.Typings(app.win.CurrentBuffer()) + ts := s.Typings(buffer) status := "" if 3 < len(ts) { status = "several people are typing..." -- cgit v1.2.3