summary refs log tree commit diff stats
path: root/widgets/msgviewer.go
diff options
context:
space:
mode:
Diffstat (limited to 'widgets/msgviewer.go')
-rw-r--r--widgets/msgviewer.go33
1 files changed, 31 insertions, 2 deletions
diff --git a/widgets/msgviewer.go b/widgets/msgviewer.go
index ab79b5e..64762f7 100644
--- a/widgets/msgviewer.go
+++ b/widgets/msgviewer.go
@@ -119,12 +119,13 @@ func NewMessageViewer(conf *config.AercConfig,
 		if err != nil {
 			goto handle_error
 		}
+		switcher.selected = -1
 		for i, pv := range switcher.parts {
 			pv.OnInvalidate(func(_ ui.Drawable) {
 				switcher.Invalidate()
 			})
 			// TODO: switch to user's preferred mimetype, if configured
-			if switcher.selected == 0 && pv.part.MIMEType != "multipart" {
+			if switcher.selected == -1 && pv.part.MIMEType != "multipart" {
 				switcher.selected = i
 			}
 		}
@@ -198,6 +199,34 @@ func (mv *MessageViewer) OnInvalidate(fn func(d ui.Drawable)) {
 	})
 }
 
+func (mv *MessageViewer) PreviousPart() {
+	switcher := mv.switcher
+	for {
+		switcher.selected--
+		if switcher.selected < 0 {
+			switcher.selected = len(switcher.parts) - 1
+		}
+		if switcher.parts[switcher.selected].part.MIMEType != "multipart" {
+			break
+		}
+	}
+	mv.Invalidate()
+}
+
+func (mv *MessageViewer) NextPart() {
+	switcher := mv.switcher
+	for {
+		switcher.selected++
+		if switcher.selected >= len(switcher.parts) {
+			switcher.selected = 0
+		}
+		if switcher.parts[switcher.selected].part.MIMEType != "multipart" {
+			break
+		}
+	}
+	mv.Invalidate()
+}
+
 func (ps *PartSwitcher) Invalidate() {
 	ps.DoInvalidate(ps)
 }
@@ -318,7 +347,7 @@ func NewPartViewer(conf *config.AercConfig,
 
 	pv := &PartViewer{
 		filter:  filter,
-		index:   index, // TODO: Nested multipart does indicies differently
+		index:   index,
 		msg:     msg,
 		pager:   pager,
 		pagerin: pagerin,
72e0e180c04'>e4ac3c9e ^
805d58c6 ^
ac07e589 ^



c5ffb6e1 ^

a654e4ec ^



e5c11a51 ^






















a654e4ec ^

c5ffb6e1 ^
e5c11a51 ^
e4ac3c9e ^
a654e4ec ^
204dae92 ^

b301e0c0 ^
204dae92 ^
3ea092f2 ^



1437d841 ^
3ea092f2 ^















c5ffb6e1 ^


a654e4ec ^
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