about summary refs log tree commit diff stats
path: root/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'widgets')
-rw-r--r--widgets/account.go4
-rw-r--r--widgets/msglist.go20
2 files changed, 24 insertions, 0 deletions
diff --git a/widgets/account.go b/widgets/account.go
index 82d2cad..f5e24d2 100644
--- a/widgets/account.go
+++ b/widgets/account.go
@@ -172,6 +172,10 @@ func (acct *AccountView) Directories() *DirectoryList {
 	return acct.dirlist
 }
 
+func (acct *AccountView) Messages() *MessageList {
+	return acct.msglist
+}
+
 func (acct *AccountView) onMessage(msg types.WorkerMessage) {
 	switch msg := msg.(type) {
 	case *types.Done:
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)
+}