summary refs log tree commit diff stats
path: root/widgets/msgviewer.go
diff options
context:
space:
mode:
authorJeffas <dev@jeffas.io>2019-07-17 21:51:02 +0100
committerDrew DeVault <sir@cmpwn.com>2019-07-17 17:34:43 -0400
commitfb124139f3a84c03708079e45c2f7d41d6ededca (patch)
tree042131a7f9ccaec78ed5de8a867ee5c22cb5b720 /widgets/msgviewer.go
parent4a5aa7dc27cd1b48db4d6211f74e909de1aa558d (diff)
downloadaerc-fb124139f3a84c03708079e45c2f7d41d6ededca.tar.gz
Add option to always show mimetype in viewer
A user may want to be able to see what mimetype they are viewing, so
that they can determine what program it may be opened in or for some
other reason.

The config option is under the [viewer] section and is called
'always-show-mime'. It defaults to false to preserve the current
behaviour.
Diffstat (limited to 'widgets/msgviewer.go')
-rw-r--r--widgets/msgviewer.go10
1 files changed, 6 insertions, 4 deletions
diff --git a/widgets/msgviewer.go b/widgets/msgviewer.go
index 1f0b0e4..3f9b7fe 100644
--- a/widgets/msgviewer.go
+++ b/widgets/msgviewer.go
@@ -38,9 +38,10 @@ type MessageViewer struct {
 
 type PartSwitcher struct {
 	ui.Invalidatable
-	parts       []*PartViewer
-	selected    int
-	showHeaders bool
+	parts          []*PartViewer
+	selected       int
+	showHeaders    bool
+	alwaysShowMime bool
 }
 
 func NewMessageViewer(acct *AccountView, conf *config.AercConfig,
@@ -165,6 +166,7 @@ func createSwitcher(switcher *PartSwitcher, conf *config.AercConfig,
 	store *lib.MessageStore, msg *models.MessageInfo) error {
 	var err error
 	switcher.showHeaders = conf.Viewer.ShowHeaders
+	switcher.alwaysShowMime = conf.Viewer.AlwaysShowMime
 
 	if len(msg.BodyStructure.Parts) == 0 {
 		switcher.selected = 0
@@ -312,7 +314,7 @@ func (ps *PartSwitcher) Event(event tcell.Event) bool {
 
 func (ps *PartSwitcher) Draw(ctx *ui.Context) {
 	height := len(ps.parts)
-	if height == 1 {
+	if height == 1 && !ps.alwaysShowMime {
 		ps.parts[ps.selected].Draw(ctx)
 		return
 	}