summary refs log tree commit diff stats
path: root/widgets
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2019-03-31 12:35:51 -0400
committerDrew DeVault <sir@cmpwn.com>2019-03-31 12:35:51 -0400
commit0abafa60e159f87595148c0d0fc4f5f46be2d400 (patch)
tree1f6cc2059c1d9d712dd60e00146b7a7caa9b1c59 /widgets
parent95875b13f829919b3453763628d1dda97371fab0 (diff)
downloadaerc-0abafa60e159f87595148c0d0fc4f5f46be2d400.tar.gz
Make message viewer real, part two
Diffstat (limited to 'widgets')
-rw-r--r--widgets/account.go2
-rw-r--r--widgets/msgviewer.go32
2 files changed, 23 insertions, 11 deletions
diff --git a/widgets/account.go b/widgets/account.go
index f26d838..f8abdc9 100644
--- a/widgets/account.go
+++ b/widgets/account.go
@@ -173,7 +173,7 @@ func (acct *AccountView) onMessage(msg types.WorkerMessage) {
 	case *types.DirectoryContents:
 		store := acct.msgStores[acct.dirlist.selected]
 		store.Update(msg)
-	case *types.MessageBody:
+	case *types.FullMessage:
 		store := acct.msgStores[acct.dirlist.selected]
 		store.Update(msg)
 	case *types.MessageInfo:
diff --git a/widgets/msgviewer.go b/widgets/msgviewer.go
index 2c77aeb..c7ac44c 100644
--- a/widgets/msgviewer.go
+++ b/widgets/msgviewer.go
@@ -16,10 +16,11 @@ import (
 )
 
 type MessageViewer struct {
-	mail io.Reader
-	pipe io.Writer
-	grid *ui.Grid
-	term *Terminal
+	cmd    *exec.Cmd
+	source io.Reader
+	sink   io.WriteCloser
+	grid   *ui.Grid
+	term   *Terminal
 }
 
 func formatAddresses(addrs []*imap.Address) string {
@@ -92,22 +93,33 @@ func NewMessageViewer(store *lib.MessageStore,
 	grid.AddChild(body).At(1, 0)
 
 	viewer := &MessageViewer{
-		pipe: pipe,
+		cmd:  cmd,
+		sink: pipe,
 		grid: grid,
 		term: term,
 	}
 
 	store.FetchBodyPart(msg.Uid, 0, func(reader io.Reader) {
-		viewer.mail = reader
-		go func() {
-			io.Copy(pipe, reader)
-			pipe.Close()
-		}()
+		viewer.source = reader
+		viewer.attemptCopy()
 	})
 
+	term.OnStart = func() {
+		viewer.attemptCopy()
+	}
+
 	return viewer
 }
 
+func (mv *MessageViewer) attemptCopy() {
+	if mv.source != nil && mv.cmd.Process != nil {
+		go func() {
+			io.Copy(mv.sink, mv.source)
+			mv.sink.Close()
+		}()
+	}
+}
+
 func (mv *MessageViewer) Draw(ctx *ui.Context) {
 	mv.grid.Draw(ctx)
 }
-21 11:30:52 +0100 committer Anselm R. Garbe <arg@suckless.org> 2007-02-21 11:30:52 +0100 cleaned up and commented the config.*.h' href='/acidbong/suckless/dwm/commit/config.default.h?h=4.4&id=f196b71e4d543e7d8c4fd6398cf1bedd3dafc024'>f196b71 ^
3794c62 ^
f196b71 ^
3794c62 ^
f196b71 ^
3794c62 ^

338c083 ^
3794c62 ^
3d1d75a ^
f196b71 ^
cac492b ^
3794c62 ^
f196b71 ^

b515765 ^
b515765 ^
19dcbc5 ^
2c477cf ^
0ea0343 ^
2c477cf ^
0ea0343 ^
35f08f4 ^
2122e39 ^

0ea0343 ^

2c477cf ^

338c083 ^
2c477cf ^







































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