about summary refs log tree commit diff stats
path: root/widgets/msgviewer.go
diff options
context:
space:
mode:
authorGalen Abell <galen@galenabell.com>2019-05-26 17:37:39 -0400
committerDrew DeVault <sir@cmpwn.com>2019-05-27 09:37:07 -0400
commit28fc9fa53da1449498392f83d63a8502a5a958a3 (patch)
tree5c940758d297ca88f47f24344da3e8ee08e998bc /widgets/msgviewer.go
parent62cd0b08aa82fe19e6d5d96b0341f7cffbb4cb7b (diff)
downloadaerc-28fc9fa53da1449498392f83d63a8502a5a958a3.tar.gz
Add :save and :pipe commands to viewer
* :save takes a path and saves the current message part to that location
* :pipe is the same as pipe on the account page, but uses the current
  message part rather than the whole email (ie :pipe gzip -d)
* Refactored account:pipe and extracted common pipe code to
  commands.util.QuickTerm
* Added helper command aerc.PushError
Diffstat (limited to 'widgets/msgviewer.go')
-rw-r--r--widgets/msgviewer.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/widgets/msgviewer.go b/widgets/msgviewer.go
index e0fe6aa..d31e051 100644
--- a/widgets/msgviewer.go
+++ b/widgets/msgviewer.go
@@ -199,6 +199,18 @@ func (mv *MessageViewer) OnInvalidate(fn func(d ui.Drawable)) {
 	})
 }
 
+func (mv *MessageViewer) CurrentPart() *PartInfo {
+	switcher := mv.switcher
+	part := switcher.parts[switcher.selected]
+
+	return &PartInfo{
+		Index: part.index,
+		Msg:   part.msg,
+		Part:  part.part,
+		Store: part.store,
+	}
+}
+
 func (mv *MessageViewer) PreviousPart() {
 	switcher := mv.switcher
 	for {
@@ -291,6 +303,13 @@ type PartViewer struct {
 	term    *Terminal
 }
 
+type PartInfo struct {
+	Index []int
+	Msg   *types.MessageInfo
+	Part  *imap.BodyStructure
+	Store *lib.MessageStore
+}
+
 func NewPartViewer(conf *config.AercConfig,
 	store *lib.MessageStore, msg *types.MessageInfo,
 	part *imap.BodyStructure, index []int) (*PartViewer, error) {