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). --- ui/ui.go | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'ui/ui.go') diff --git a/ui/ui.go b/ui/ui.go index d1007cb..5f87fe3 100644 --- a/ui/ui.go +++ b/ui/ui.go @@ -82,7 +82,7 @@ func (ui *UI) Close() { ui.screen.Fini() } -func (ui *UI) CurrentBuffer() string { +func (ui *UI) CurrentBuffer() (netID, title string) { return ui.bs.Current() } @@ -147,8 +147,8 @@ func (ui *UI) IsAtTop() bool { return ui.bs.IsAtTop() } -func (ui *UI) AddBuffer(title string) (i int, added bool) { - return ui.bs.Add(title) +func (ui *UI) AddBuffer(netID, netName, title string) (i int, added bool) { + return ui.bs.Add(netID, netName, title) } func (ui *UI) RemoveBuffer(title string) { @@ -156,12 +156,12 @@ func (ui *UI) RemoveBuffer(title string) { ui.memberOffset = 0 } -func (ui *UI) AddLine(buffer string, notify NotifyType, line Line) { - ui.bs.AddLine(buffer, notify, line) +func (ui *UI) AddLine(netID, buffer string, notify NotifyType, line Line) { + ui.bs.AddLine(netID, buffer, notify, line) } -func (ui *UI) AddLines(buffer string, before, after []Line) { - ui.bs.AddLines(buffer, before, after) +func (ui *UI) AddLines(netID, buffer string, before, after []Line) { + ui.bs.AddLines(netID, buffer, before, after) } func (ui *UI) JumpBuffer(sub string) bool { @@ -188,6 +188,19 @@ func (ui *UI) JumpBufferIndex(i int) bool { return false } +func (ui *UI) JumpBufferNetwork(netID, sub string) bool { + subLower := strings.ToLower(sub) + for i, b := range ui.bs.list { + if b.netID == netID && strings.Contains(strings.ToLower(b.title), subLower) { + if ui.bs.To(i) { + ui.memberOffset = 0 + } + return true + } + } + return false +} + func (ui *UI) SetStatus(status string) { ui.status = status } -- cgit v1.2.3