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.
This commit is contained in:
Jeffas 2019-07-17 21:51:02 +01:00 committed by Drew DeVault
parent 4a5aa7dc27
commit fb124139f3
4 changed files with 21 additions and 8 deletions

View File

@ -69,6 +69,11 @@ show-headers=false
# Default: From|To,Cc|Bcc,Date,Subject # Default: From|To,Cc|Bcc,Date,Subject
header-layout=From|To,Cc|Bcc,Date,Subject header-layout=From|To,Cc|Bcc,Date,Subject
# Whether to always show the mimetype of an email, even when it is just a single part
#
# Default: false
always-show-mime=false
[compose] [compose]
# #
# Specifies the command to run the editor with. It will be shown in an embedded # Specifies the command to run the editor with. It will be shown in an embedded

View File

@ -77,10 +77,11 @@ type FilterConfig struct {
} }
type ViewerConfig struct { type ViewerConfig struct {
Pager string Pager string
Alternatives []string Alternatives []string
ShowHeaders bool `ini:"show-headers"` ShowHeaders bool `ini:"show-headers"`
HeaderLayout [][]string `ini:"-"` AlwaysShowMime bool `ini:"always-show-mime"`
HeaderLayout [][]string `ini:"-"`
} }
type AercConfig struct { type AercConfig struct {

View File

@ -133,6 +133,11 @@ These options are configured in the *[viewer]* section of aerc.conf.
Default: false Default: false
*always-show-mime*
Whether to always show the mimetype of an email, even when it is just a single part.
Default: false
## COMPOSE ## COMPOSE
These options are configured in the *[compose]* section of aerc.conf. These options are configured in the *[compose]* section of aerc.conf.

View File

@ -38,9 +38,10 @@ type MessageViewer struct {
type PartSwitcher struct { type PartSwitcher struct {
ui.Invalidatable ui.Invalidatable
parts []*PartViewer parts []*PartViewer
selected int selected int
showHeaders bool showHeaders bool
alwaysShowMime bool
} }
func NewMessageViewer(acct *AccountView, conf *config.AercConfig, 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 { store *lib.MessageStore, msg *models.MessageInfo) error {
var err error var err error
switcher.showHeaders = conf.Viewer.ShowHeaders switcher.showHeaders = conf.Viewer.ShowHeaders
switcher.alwaysShowMime = conf.Viewer.AlwaysShowMime
if len(msg.BodyStructure.Parts) == 0 { if len(msg.BodyStructure.Parts) == 0 {
switcher.selected = 0 switcher.selected = 0
@ -312,7 +314,7 @@ func (ps *PartSwitcher) Event(event tcell.Event) bool {
func (ps *PartSwitcher) Draw(ctx *ui.Context) { func (ps *PartSwitcher) Draw(ctx *ui.Context) {
height := len(ps.parts) height := len(ps.parts)
if height == 1 { if height == 1 && !ps.alwaysShowMime {
ps.parts[ps.selected].Draw(ctx) ps.parts[ps.selected].Draw(ctx)
return return
} }