summaryrefslogtreecommitdiff
path: root/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'widgets')
-rw-r--r--widgets/msglist.go7
-rw-r--r--widgets/msgviewer.go28
2 files changed, 11 insertions, 24 deletions
diff --git a/widgets/msglist.go b/widgets/msglist.go
index caa868f..f1cbb31 100644
--- a/widgets/msglist.go
+++ b/widgets/msglist.go
@@ -80,7 +80,12 @@ func (ml *MessageList) Draw(ctx *ui.Context) {
style = style.Foreground(tcell.ColorGray)
}
ctx.Fill(0, row, ctx.Width(), 1, ' ', style)
- ctx.Printf(0, row, style, "%s", msg.Envelope.Subject)
+ fmtStr, args, err := lib.ParseIndexFormat(ml.conf, i, msg)
+ if err != nil {
+ ctx.Printf(0, row, style, "%v", err)
+ } else {
+ ctx.Printf(0, row, style, fmtStr, args...)
+ }
row += 1
}
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)