summaryrefslogtreecommitdiff
path: root/ui/ui.go
diff options
context:
space:
mode:
authorHubert Hirtz <hubert@hirtz.pm>2021-10-20 17:33:10 +0200
committerHubert Hirtz <hubert@hirtz.pm>2021-10-24 12:57:24 +0200
commit9fb4378753ddec61a504a0dec403f40d6def7e90 (patch)
tree32955930be2d97614f3ec6290f67d0556769a16e /ui/ui.go
parentRemove draft file (diff)
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).
Diffstat (limited to 'ui/ui.go')
-rw-r--r--ui/ui.go27
1 files changed, 20 insertions, 7 deletions
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
}