diff options
author | Yash Srivastav <yash111998@gmail.com> | 2019-06-08 01:05:23 +0530 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2019-06-07 16:22:01 -0400 |
commit | fca7321639f77bbf825dc897156d7a21993a2c69 (patch) | |
tree | 5e503bf4ebd9672eef2af5cbad49b5b73405e548 /widgets/msgviewer.go | |
parent | 6d491569c0f95bec03cc837446c2836acabe99ae (diff) | |
download | aerc-fca7321639f77bbf825dc897156d7a21993a2c69.tar.gz |
Message list: implement index-format option
Diffstat (limited to 'widgets/msgviewer.go')
-rw-r--r-- | widgets/msgviewer.go | 28 |
1 files changed, 5 insertions, 23 deletions
diff --git a/widgets/msgviewer.go b/widgets/msgviewer.go index 6017e50..52407b7 100644 --- a/widgets/msgviewer.go +++ b/widgets/msgviewer.go @@ -2,7 +2,6 @@ package widgets import ( "bufio" - "bytes" "fmt" "io" "os/exec" @@ -44,23 +43,6 @@ type PartSwitcher struct { showHeaders bool } -func formatAddresses(addrs []*imap.Address) string { - val := bytes.Buffer{} - for i, addr := range addrs { - if addr.PersonalName != "" { - val.WriteString(fmt.Sprintf("%s <%s@%s>", - addr.PersonalName, addr.MailboxName, addr.HostName)) - } else { - val.WriteString(fmt.Sprintf("%s@%s", - addr.MailboxName, addr.HostName)) - } - if i != len(addrs)-1 { - val.WriteString(", ") - } - } - return val.String() -} - func NewMessageViewer(acct *AccountView, conf *config.AercConfig, store *lib.MessageStore, msg *types.MessageInfo) *MessageViewer { @@ -84,12 +66,12 @@ func NewMessageViewer(acct *AccountView, conf *config.AercConfig, headers.AddChild( &HeaderView{ Name: "From", - Value: formatAddresses(msg.Envelope.From), + Value: lib.FormatAddresses(msg.Envelope.From), }).At(0, 0) headers.AddChild( &HeaderView{ Name: "To", - Value: formatAddresses(msg.Envelope.To), + Value: lib.FormatAddresses(msg.Envelope.To), }).At(0, 1) headers.AddChild( &HeaderView{ @@ -379,11 +361,11 @@ func NewPartViewer(conf *config.AercConfig, case "subject": header = msg.Envelope.Subject case "from": - header = formatAddresses(msg.Envelope.From) + header = lib.FormatAddresses(msg.Envelope.From) case "to": - header = formatAddresses(msg.Envelope.To) + header = lib.FormatAddresses(msg.Envelope.To) case "cc": - header = formatAddresses(msg.Envelope.Cc) + header = lib.FormatAddresses(msg.Envelope.Cc) } if f.Regex.Match([]byte(header)) { filter = exec.Command("sh", "-c", f.Command) |