about summary refs log tree commit diff stats
path: root/widgets/msglist.go
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2019-03-14 23:41:25 -0400
committerDrew DeVault <sir@cmpwn.com>2019-03-14 23:41:25 -0400
commit24daef89e0fc6056c3ff7b94880ed12b4ec3eaa6 (patch)
tree82bffc5ee8ec795d07833734929907db0f659f85 /widgets/msglist.go
parent4c8feb9aa54ddb162558482905c4723e2743e657 (diff)
downloadaerc-24daef89e0fc6056c3ff7b94880ed12b4ec3eaa6.tar.gz
Implement :{next,prev}-message
Diffstat (limited to 'widgets/msglist.go')
-rw-r--r--widgets/msglist.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/widgets/msglist.go b/widgets/msglist.go
index e004e0e..36d7f7a 100644
--- a/widgets/msglist.go
+++ b/widgets/msglist.go
@@ -180,3 +180,23 @@ func (ml *MessageList) SetStore(store *MessageStore) {
 	}
 	ml.Invalidate()
 }
+
+func (ml *MessageList) nextPrev(delta int) {
+	ml.selected += delta
+	if ml.selected < 0 {
+		ml.selected = len(ml.store.Uids) - 1
+	}
+	if ml.selected >= len(ml.store.Uids) {
+		ml.selected = 0
+	}
+	// TODO: scrolling
+	ml.Invalidate()
+}
+
+func (ml *MessageList) Next() {
+	ml.nextPrev(1)
+}
+
+func (ml *MessageList) Prev() {
+	ml.nextPrev(-1)
+}