diff options
author | delthas <delthas@dille.cc> | 2021-07-13 19:26:24 +0200 |
---|---|---|
committer | Hubert Hirtz <hubert@hirtz.pm> | 2021-07-13 21:38:53 +0200 |
commit | 93005741f2fa5c16bed3d7bc325c7d09a6a507da (patch) | |
tree | 2373fbf66cc6987ab7f3c6f1a1f4b0238fea9049 /ui | |
parent | Clear 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.go | 9 | ||||
-rw-r--r-- | ui/ui.go | 12 |
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) { @@ -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 } |