summaryrefslogtreecommitdiff
path: root/client/channel_list.go
diff options
context:
space:
mode:
authorcitrons <citrons@mondecitronne.com>2025-06-07 14:57:04 -0500
committercitrons <citrons@mondecitronne.com>2025-06-07 16:02:18 -0500
commit855e61c53c8a401c6f0be84a63808cb94cb19903 (patch)
tree5f03c5357cf6aa75db05376cf6a42cc67d1e33c8 /client/channel_list.go
parent553ebc26cda61b567418205f7ee60be122b3c84f (diff)
channel list scrolling
Diffstat (limited to 'client/channel_list.go')
-rw-r--r--client/channel_list.go44
1 files changed, 25 insertions, 19 deletions
diff --git a/client/channel_list.go b/client/channel_list.go
index 6ac2141..f7413fd 100644
--- a/client/channel_list.go
+++ b/client/channel_list.go
@@ -52,9 +52,9 @@ func (cl *channelList) remove(location channelLocation) {
}
}
-func (cl *channelList) traverse(direction int) {
+func (cl *channelList) traverse(direction int) int {
if len(*cl) == 0 {
- return
+ return 0
}
var i int
@@ -73,6 +73,7 @@ func (cl *channelList) traverse(direction int) {
}
}
globalApp.goTo((*cl)[i].location)
+ return i
}
func (cl *channelList) add(name string, location channelLocation) {
@@ -81,8 +82,11 @@ func (cl *channelList) add(name string, location channelLocation) {
*cl = append([]channelListEntry {entry}, *cl...)
}
-func (cl *channelList) show() {
- mouse := tui.Push("channel list", tui.Box {Width: 12, Height: tui.Fill})
+func (cl *channelList) show(scroll *tui.ScrollState) {
+ mouse := tui.Push("channel list", tui.Box {
+ Width: 12, Height: tui.Fill, Overflow: true, Scroll: scroll,
+ })
+ scroll.ByMouse(mouse, false)
for i, entry := range *cl {
var style *tui.Style
if entry.location == globalApp.currentWindow {
@@ -95,20 +99,22 @@ func (cl *channelList) show() {
Width: tui.Fill, Height: 1, NoWrap: true, Style: style,
})
- if mouse.Pressed {
- globalApp.redraw = true
- entry.clicked = true
- }
- if mouse.Released {
- globalApp.redraw = true
- if entry.clicked {
- globalApp.goTo(entry.location)
- } else {
- for j, entry2 := range *cl {
- if entry2.clicked {
- entry2.clicked = false
- (*cl)[j] = entry
- entry = entry2
+ if mouse.Button == 0 {
+ if mouse.Pressed {
+ globalApp.redraw = true
+ entry.clicked = true
+ }
+ if mouse.Released {
+ globalApp.redraw = true
+ if entry.clicked {
+ globalApp.goTo(entry.location)
+ } else {
+ for j, entry2 := range *cl {
+ if entry2.clicked {
+ entry2.clicked = false
+ (*cl)[j] = entry
+ entry = entry2
+ }
}
}
}
@@ -124,7 +130,7 @@ func (cl *channelList) show() {
(*cl)[i] = entry
}
- if mouse.ReleasedAnywhere {
+ if mouse.Button == 0 && mouse.ReleasedAnywhere {
for i, entry := range *cl {
globalApp.redraw = globalApp.redraw || entry.clicked
entry.clicked = false