Show attachment names in multipart view

This commit is contained in:
Drew DeVault 2019-05-20 17:03:37 -04:00
parent 0897413a3e
commit d224487b68
1 changed files with 5 additions and 1 deletions

View File

@ -255,9 +255,13 @@ func (ps *PartSwitcher) Draw(ctx *ui.Context) {
for i, part := range ps.parts { for i, part := range ps.parts {
style := tcell.StyleDefault.Reverse(ps.selected == i) style := tcell.StyleDefault.Reverse(ps.selected == i)
ctx.Fill(0, y+i, ctx.Width(), 1, ' ', style) ctx.Fill(0, y+i, ctx.Width(), 1, ' ', style)
ctx.Printf(len(part.index)*2, y+i, style, "%s/%s", name := fmt.Sprintf("%s/%s",
strings.ToLower(part.part.MIMEType), strings.ToLower(part.part.MIMEType),
strings.ToLower(part.part.MIMESubType)) strings.ToLower(part.part.MIMESubType))
if filename, ok := part.part.DispositionParams["filename"]; ok {
name += fmt.Sprintf(" (%s)", filename)
}
ctx.Printf(len(part.index)*2, y+i, style, "%s", name)
} }
ps.parts[ps.selected].Draw(ctx.Subcontext( ps.parts[ps.selected].Draw(ctx.Subcontext(
0, 0, ctx.Width(), ctx.Height()-height)) 0, 0, ctx.Width(), ctx.Height()-height))