37 lines
759 B
Go
37 lines
759 B
Go
|
package compose
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"git.sr.ht/~rjarry/aerc/widgets"
|
||
|
)
|
||
|
|
||
|
type MarkUp struct{}
|
||
|
|
||
|
func init() {
|
||
|
register(MarkUp{})
|
||
|
}
|
||
|
|
||
|
func (MarkUp) Aliases() []string {
|
||
|
return []string{"markup"}
|
||
|
}
|
||
|
|
||
|
func (MarkUp) Complete(aerc *widgets.Aerc, args []string) []string {
|
||
|
composer, _ := aerc.SelectedTabContent().(*widgets.Composer)
|
||
|
return composer.GetMarkups()
|
||
|
}
|
||
|
|
||
|
func (MarkUp) Execute(aerc *widgets.Aerc, args []string) error {
|
||
|
if len(args) != 2 {
|
||
|
return fmt.Errorf("Usage: :markup <label>")
|
||
|
}
|
||
|
markupKey := args[1]
|
||
|
composer, _ := aerc.SelectedTabContent().(*widgets.Composer)
|
||
|
if err := composer.GenerateMarkup(markupKey); err != nil {
|
||
|
aerc.PushError(err.Error())
|
||
|
return err
|
||
|
} else {
|
||
|
aerc.PushSuccess(fmt.Sprintf("Markup generated"))
|
||
|
}
|
||
|
return nil
|
||
|
}
|