summaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
authordelthas <delthas@dille.cc>2021-07-13 19:26:24 +0200
committerHubert Hirtz <hubert@hirtz.pm>2021-07-13 21:38:53 +0200
commit93005741f2fa5c16bed3d7bc325c7d09a6a507da (patch)
tree2373fbf66cc6987ab7f3c6f1a1f4b0238fea9049 /ui
parentClear the input on CTRL+C instead of quitting (diff)
Switch to the buffer of a new user-requested channel join
Diffstat (limited to '')
-rw-r--r--ui/buffers.go9
-rw-r--r--ui/ui.go12
2 files changed, 14 insertions, 7 deletions
diff --git a/ui/buffers.go b/ui/buffers.go
index 297f70e..6de3923 100644
--- a/ui/buffers.go
+++ b/ui/buffers.go
@@ -224,17 +224,16 @@ func (bs *BufferList) Previous() {
bs.list[bs.current].unread = false
}
-func (bs *BufferList) Add(title string) (ok bool) {
+func (bs *BufferList) Add(title string) int {
lTitle := strings.ToLower(title)
- for _, b := range bs.list {
+ for i, b := range bs.list {
if strings.ToLower(b.title) == lTitle {
- return
+ return i
}
}
- ok = true
bs.list = append(bs.list, buffer{title: title})
- return
+ return len(bs.list) - 1
}
func (bs *BufferList) Remove(title string) (ok bool) {
diff --git a/ui/ui.go b/ui/ui.go
index 4ced9f0..6fe0798 100644
--- a/ui/ui.go
+++ b/ui/ui.go
@@ -128,8 +128,8 @@ func (ui *UI) IsAtTop() bool {
return ui.bs.IsAtTop()
}
-func (ui *UI) AddBuffer(title string) {
- _ = ui.bs.Add(title)
+func (ui *UI) AddBuffer(title string) int {
+ return ui.bs.Add(title)
}
func (ui *UI) RemoveBuffer(title string) {
@@ -156,6 +156,14 @@ func (ui *UI) JumpBuffer(sub string) bool {
return false
}
+func (ui *UI) JumpBufferIndex(i int) bool {
+ if i >= 0 && i < len(ui.bs.list) {
+ ui.bs.To(i)
+ return true
+ }
+ return false
+}
+
func (ui *UI) SetStatus(status string) {
ui.status = status
}