summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorraven <citrons@mondecitronne.com>2026-02-17 16:41:28 -0600
committerraven <citrons@mondecitronne.com>2026-02-17 16:41:28 -0600
commit7b3792369672ea758fd6e89ce80fa0de49737bad (patch)
treeb16778ab4d9f807495c30a4df1d1d54bbb574fbf
parente85058daf7019777ac017a84253298390bcf2745 (diff)
alt+arrow navigation through DM list
-rw-r--r--client/channel_list.go7
-rw-r--r--client/ui.go43
2 files changed, 43 insertions, 7 deletions
diff --git a/client/channel_list.go b/client/channel_list.go
index 2c7c51c..cfb1ec4 100644
--- a/client/channel_list.go
+++ b/client/channel_list.go
@@ -91,7 +91,12 @@ func (cl *channelList) remove(location channelLocation) {
}
func (cl *channelList) traverse(direction int) int {
- next := 0
+ var next int
+ if direction >= 0 {
+ next = 0
+ } else {
+ next = len(*cl) - 1
+ }
for i := 0; i < len(*cl); i++ {
if (*cl)[i].location == globalApp.currentWindow {
next = i + direction
diff --git a/client/ui.go b/client/ui.go
index 6282bc6..8d55519 100644
--- a/client/ui.go
+++ b/client/ui.go
@@ -104,12 +104,43 @@ func (a *application) onInput(ev tui.Event) {
prompt.Input().Write("")
}
- case keys.Up | keys.Alt:
- index := a.channelList.traverse(-1)
- a.channelScroll.Set(index - 5)
- case keys.Down | keys.Alt:
- index := a.channelList.traverse(1)
- a.channelScroll.Set(index - 5)
+ case keys.Up | keys.Alt, keys.Down | keys.Alt:
+ var dir int
+ if ev.Key == keys.Up | keys.Alt {
+ dir = -1
+ } else {
+ dir = 1
+ }
+ var loc channelLocation
+ switch w := a.currentWindow.(type) {
+ case channelLocation:
+ loc = w
+ }
+ switch {
+ case a.channelList.contains(loc):
+ index := a.channelList.traverse(dir)
+ if index >= 0 && index < a.channelList.Len() {
+ a.channelScroll.Set(index - 5)
+ break
+ }
+ fallthrough
+ case a.dmList.contains(loc):
+ index := a.dmList.traverse(dir)
+ if index >= 0 && index < a.dmList.Len() {
+ a.dmScroll.Set(index - 5)
+ } else {
+ index = a.channelList.traverse(dir)
+ a.channelScroll.Set(index - 5)
+ }
+ default:
+ if ev.Key == keys.Down | keys.Alt {
+ a.channelList.traverse(0)
+ a.channelScroll.Set(0)
+ } else {
+ a.dmList.traverse(0)
+ a.dmScroll.Set(0)
+ }
+ }
case 'p' | keys.Ctrl:
a.traverseHistory(-1)