about summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/msgstore.go41
1 files changed, 41 insertions, 0 deletions
diff --git a/lib/msgstore.go b/lib/msgstore.go
index 5b4d540..a81f9ad 100644
--- a/lib/msgstore.go
+++ b/lib/msgstore.go
@@ -17,6 +17,7 @@ type MessageStore struct {
 	// Ordered list of known UIDs
 	Uids []uint32
 
+	selected        int
 	bodyCallbacks   map[uint32][]func(io.Reader)
 	headerCallbacks map[uint32][]func(*types.MessageInfo)
 
@@ -34,6 +35,7 @@ func NewMessageStore(worker *types.Worker,
 		Deleted: make(map[uint32]interface{}),
 		DirInfo: *dirInfo,
 
+		selected:        0,
 		bodyCallbacks:   make(map[uint32][]func(io.Reader)),
 		headerCallbacks: make(map[uint32][]func(*types.MessageInfo)),
 
@@ -279,3 +281,42 @@ func (store *MessageStore) Read(uids []uint32, read bool,
 		Uids: set,
 	}, cb)
 }
+
+func (store *MessageStore) Selected() *types.MessageInfo {
+	return store.Messages[store.Uids[len(store.Uids)-store.selected-1]]
+}
+
+func (store *MessageStore) SelectedIndex() int {
+	return store.selected
+}
+
+func (store *MessageStore) Select(index int) {
+	store.selected = index
+	for ; store.selected < 0; store.selected = len(store.Uids) + store.selected {
+		/* This space deliberately left blank */
+	}
+	if store.selected > len(store.Uids) {
+		store.selected = len(store.Uids)
+	}
+}
+
+func (store *MessageStore) nextPrev(delta int) {
+	if len(store.Uids) == 0 {
+		return
+	}
+	store.selected += delta
+	if store.selected < 0 {
+		store.selected = 0
+	}
+	if store.selected >= len(store.Uids) {
+		store.selected = len(store.Uids) - 1
+	}
+}
+
+func (store *MessageStore) Next() {
+	store.nextPrev(1)
+}
+
+func (store *MessageStore) Prev() {
+	store.nextPrev(-1)
+}
a title='author Anselm R. Garbe <arg@10kloc.org> 2006-09-12 09:46:19 +0200 committer Anselm R. Garbe <arg@10kloc.org> 2006-09-12 09:46:19 +0200 made introduction comment in dwm.h shorter' href='/acidbong/suckless/dwm/commit/dwm.h?h=5.8.2&id=cbfc69e310e41cf0d9d4ae7529856014f2b88822'>cbfc69e ^
cdbc84b ^

e6cc223 ^
551d6bb ^
1076f2b

b515765 ^
95e8d12 ^
8b59083 ^
7b5638f ^
7c2e3bb ^
7b5638f ^
2aef8b9 ^
281f098 ^
0045ad8 ^
2aef8b9 ^
96d7fe1 ^
281f098 ^
b5159df ^
1076f2b
da2bbd3 ^
1173723 ^
346bdea ^
a05beb6 ^
9ca5c3b ^
a05beb6 ^
22399a3 ^
338c083 ^
b355755 ^
1076f2b
72707c2 ^
15abade ^
bf35794 ^
1076f2b

cdbc84b ^
8d11163 ^













b3419f4 ^






36672d0 ^
86953bd ^
b3419f4 ^



b3419f4 ^
39677ec ^
439e15d ^
1df4559 ^
83aa110 ^
1df4559 ^

199a601 ^
2aef8b9 ^
1df4559 ^

f841501 ^
83aa110 ^
36672d0 ^
2aef8b9 ^
1df4559 ^
3399650 ^
e750878 ^
1df4559 ^


e750878 ^
dba2306 ^
1df4559 ^
b9da4b0 ^
9e8b325 ^
96d7fe1 ^

b975c47 ^
1df4559 ^
9e8b325 ^
47765f7 ^
50be6c8 ^
47765f7 ^
1df4559 ^
47765f7 ^





1df4559 ^
47765f7 ^


ab3d6a7 ^
47765f7 ^
10d13f0 ^
47765f7 ^
2aef8b9 ^
1df4559 ^
b975c47 ^
1df4559 ^
4cdbd52 ^

1df4559 ^


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146