summaryrefslogtreecommitdiff
path: root/ui/buffers.go
diff options
context:
space:
mode:
authordelthas <delthas@dille.cc>2021-07-15 17:31:40 +0200
committerHubert Hirtz <hubert@hirtz.pm>2021-08-06 13:33:38 +0200
commitd8c4582bcabbd4f4506797371216d8ecb766b43d (patch)
tree02b1c52fb5f55f5fab7da19bfcbe0471532aeae9 /ui/buffers.go
parentUpdate copyright to include all contributors (diff)
Enable scrolling through the vertical member list with the mouse wheel
Diffstat (limited to 'ui/buffers.go')
-rw-r--r--ui/buffers.go18
1 files changed, 15 insertions, 3 deletions
diff --git a/ui/buffers.go b/ui/buffers.go
index 3f2ae4a..91d46cd 100644
--- a/ui/buffers.go
+++ b/ui/buffers.go
@@ -207,7 +207,10 @@ func (bs *BufferList) ResizeTimeline(tlInnerWidth, tlHeight int) {
bs.tlHeight = tlHeight
}
-func (bs *BufferList) To(i int) {
+func (bs *BufferList) To(i int) bool {
+ if i == bs.current {
+ return false
+ }
if 0 <= i {
bs.current = i
if len(bs.list) <= bs.current {
@@ -215,7 +218,9 @@ func (bs *BufferList) To(i int) {
}
bs.list[bs.current].highlights = 0
bs.list[bs.current].unread = false
+ return true
}
+ return false
}
func (bs *BufferList) Next() {
@@ -437,9 +442,16 @@ func (bs *BufferList) DrawVerticalBufferList(screen tcell.Screen, x0, y0, width,
}
}
-func (bs *BufferList) DrawVerticalMemberList(screen tcell.Screen, x0, y0, width, height int, members []irc.Member) {
+func (bs *BufferList) DrawVerticalMemberList(screen tcell.Screen, x0, y0, width, height int, members []irc.Member, offset *int) {
st := tcell.StyleDefault
+ if y0+len(members)-*offset < height {
+ *offset = y0 + len(members) - height
+ if *offset < 0 {
+ *offset = 0
+ }
+ }
+
for y := y0; y < y0+height; y++ {
screen.SetContent(x0, y, 0x2502, nil, st)
for x := x0 + 1; x < x0+width; x++ {
@@ -447,7 +459,7 @@ func (bs *BufferList) DrawVerticalMemberList(screen tcell.Screen, x0, y0, width,
}
}
- for i, m := range members {
+ for i, m := range members[*offset:] {
st = tcell.StyleDefault
x := x0 + 1
y := y0 + i