9d90b70b4e
Refactor the attachment handling process in the composer. The composer can currently only handle attachments that are stored as files (or pgp keys). This patch removes this limitation so that any message part can be handled as an attachment. With this we can treat files, pgp keys and message parts on an equal footing and it will enable us also to easily forward attachments. Signed-off-by: Koni Marti <koni.marti@gmail.com> Tested-by: Tim Culverhouse <tim@timculverhouse.com>
31 lines
543 B
Go
31 lines
543 B
Go
package compose
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"git.sr.ht/~rjarry/aerc/widgets"
|
|
)
|
|
|
|
type AttachKey struct{}
|
|
|
|
func init() {
|
|
register(AttachKey{})
|
|
}
|
|
|
|
func (AttachKey) Aliases() []string {
|
|
return []string{"attach-key"}
|
|
}
|
|
|
|
func (AttachKey) Complete(aerc *widgets.Aerc, args []string) []string {
|
|
return nil
|
|
}
|
|
|
|
func (AttachKey) Execute(aerc *widgets.Aerc, args []string) error {
|
|
if len(args) != 1 {
|
|
return errors.New("Usage: attach-key")
|
|
}
|
|
|
|
composer, _ := aerc.SelectedTab().(*widgets.Composer)
|
|
|
|
return composer.SetAttachKey(!composer.AttachKey())
|
|
}
|