From 27b25174e2f0249a6a1d4ba45b70f8504b63ffb1 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Sun, 31 Mar 2019 12:14:37 -0400 Subject: Make the message viewer real, part one --- commands/account/pipe.go | 3 --- commands/account/view-message.go | 27 +++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 commands/account/view-message.go (limited to 'commands/account') diff --git a/commands/account/pipe.go b/commands/account/pipe.go index b07a860d..18130eb7 100644 --- a/commands/account/pipe.go +++ b/commands/account/pipe.go @@ -20,9 +20,6 @@ func Pipe(aerc *widgets.Aerc, args []string) error { return errors.New("Usage: :pipe [args...]") } acct := aerc.SelectedAccount() - if acct == nil { - return errors.New("No account selected") - } store := acct.Messages().Store() msg := acct.Messages().Selected() store.FetchBodies([]uint32{msg.Uid}, func(reader io.Reader) { diff --git a/commands/account/view-message.go b/commands/account/view-message.go new file mode 100644 index 00000000..bef27407 --- /dev/null +++ b/commands/account/view-message.go @@ -0,0 +1,27 @@ +package account + +import ( + "errors" + + "github.com/mattn/go-runewidth" + + "git.sr.ht/~sircmpwn/aerc2/widgets" +) + +func init() { + register("view-message", ViewMessage) +} + +func ViewMessage(aerc *widgets.Aerc, args []string) error { + if len(args) != 1 { + return errors.New("Usage: view-message") + } + acct := aerc.SelectedAccount() + store := acct.Messages().Store() + msg := acct.Messages().Selected() + viewer := widgets.NewMessageViewer(store, msg) + aerc.NewTab(viewer, runewidth.Truncate( + msg.Envelope.Subject, 32, "…")) + return nil +} + -- cgit