aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/account-wizard.go36
-rw-r--r--app/account.go24
-rw-r--r--app/aerc.go16
-rw-r--r--app/app.go80
-rw-r--r--app/compose.go44
-rw-r--r--app/msglist.go22
-rw-r--r--app/msgviewer.go2
-rw-r--r--app/status.go11
8 files changed, 149 insertions, 86 deletions
diff --git a/app/account-wizard.go b/app/account-wizard.go
index db3aae2f..9ee69627 100644
--- a/app/account-wizard.go
+++ b/app/account-wizard.go
@@ -32,7 +32,6 @@ const (
)
type AccountWizard struct {
- aerc *Aerc
step int
steps []*ui.Grid
focus int
@@ -68,7 +67,7 @@ type AccountWizard struct {
complete []ui.Interactive
}
-func showPasswordWarning(aerc *Aerc) {
+func showPasswordWarning() {
title := "ATTENTION"
text := `
The Wizard will store your passwords as clear text in:
@@ -81,12 +80,12 @@ after the setup.
`
warning := NewSelectorDialog(
title, text, []string{"OK"}, 0,
- aerc.SelectedAccountUiConfig(),
+ SelectedAccountUiConfig(),
func(_ string, _ error) {
- aerc.CloseDialog()
+ CloseDialog()
},
)
- aerc.AddDialog(warning)
+ AddDialog(warning)
}
type configStep struct {
@@ -171,10 +170,9 @@ var (
transports = []string{SSL_TLS, OAUTH, XOAUTH, STARTTLS, INSECURE}
)
-func NewAccountWizard(aerc *Aerc) *AccountWizard {
+func NewAccountWizard() *AccountWizard {
wizard := &AccountWizard{
accountName: ui.NewTextInput("", config.Ui).Prompt("> "),
- aerc: aerc,
temporary: false,
email: ui.NewTextInput("", config.Ui).Prompt("> "),
fullName: ui.NewTextInput("", config.Ui).Prompt("> "),
@@ -244,7 +242,7 @@ func NewAccountWizard(aerc *Aerc) *AccountWizard {
wizard.sourcePassword.OnFocusLost(func(_ *ui.TextInput) {
if wizard.sourcePassword.String() != "" {
once.Do(func() {
- showPasswordWarning(aerc)
+ showPasswordWarning()
})
}
})
@@ -262,7 +260,7 @@ func NewAccountWizard(aerc *Aerc) *AccountWizard {
wizard.outgoingPassword.OnChange(func(_ *ui.TextInput) {
if wizard.outgoingPassword.String() != "" {
once.Do(func() {
- showPasswordWarning(aerc)
+ showPasswordWarning()
})
}
wizard.outgoingUri()
@@ -387,7 +385,7 @@ func (wizard *AccountWizard) ConfigureTemporaryAccount(temporary bool) {
func (wizard *AccountWizard) errorFor(d ui.Interactive, err error) {
if d == nil {
- wizard.aerc.PushError(err.Error())
+ PushError(err.Error())
wizard.Invalidate()
return
}
@@ -402,7 +400,7 @@ func (wizard *AccountWizard) errorFor(d ui.Interactive, err error) {
wizard.step = step
wizard.focus = focus
wizard.Focus(true)
- wizard.aerc.PushError(err.Error())
+ PushError(err.Error())
wizard.Invalidate()
return
}
@@ -554,13 +552,13 @@ func (wizard *AccountWizard) finish(tutorial bool) {
}
config.Accounts = append(config.Accounts, account)
- view, err := NewAccountView(wizard.aerc, account, wizard.aerc, nil)
+ view, err := NewAccountView(account, nil)
if err != nil {
- wizard.aerc.NewTab(errorScreen(err.Error()), account.Name)
+ NewTab(errorScreen(err.Error()), account.Name)
return
}
- wizard.aerc.accounts[account.Name] = view
- wizard.aerc.NewTab(view, account.Name)
+ aerc.accounts[account.Name] = view
+ NewTab(view, account.Name)
if tutorial {
name := "aerc-tutorial"
@@ -573,16 +571,16 @@ func (wizard *AccountWizard) finish(tutorial bool) {
wizard.errorFor(nil, err)
return
}
- wizard.aerc.NewTab(term, "Tutorial")
+ NewTab(term, "Tutorial")
term.OnClose = func(err error) {
- wizard.aerc.RemoveTab(term, false)
+ RemoveTab(term, false)
if err != nil {
- wizard.aerc.PushError(err.Error())
+ PushError(err.Error())
}
}
}
- wizard.aerc.RemoveTab(wizard, false)
+ RemoveTab(wizard, false)
}
func splitHostPath(server string) (string, string) {
diff --git a/app/account.go b/app/account.go
index 3ab7fc8f..bcb5028a 100644
--- a/app/account.go
+++ b/app/account.go
@@ -28,7 +28,6 @@ var _ ProvidesMessages = (*AccountView)(nil)
type AccountView struct {
sync.Mutex
acct *config.AccountConfig
- aerc *Aerc
dirlist DirectoryLister
labels []string
grid *ui.Grid
@@ -58,15 +57,12 @@ func (acct *AccountView) UiConfig() *config.UIConfig {
}
func NewAccountView(
- aerc *Aerc, acct *config.AccountConfig,
- host TabHost, deferLoop chan struct{},
+ acct *config.AccountConfig, deferLoop chan struct{},
) (*AccountView, error) {
acctUiConf := config.Ui.ForAccount(acct.Name)
view := &AccountView{
acct: acct,
- aerc: aerc,
- host: host,
uiConf: acctUiConf,
}
@@ -81,7 +77,7 @@ func NewAccountView(
worker, err := worker.NewWorker(acct.Source, acct.Name)
if err != nil {
- host.SetError(fmt.Sprintf("%s: %s", acct.Name, err))
+ SetError(fmt.Sprintf("%s: %s", acct.Name, err))
log.Errorf("%s: %v", acct.Name, err)
return view, err
}
@@ -92,7 +88,7 @@ func NewAccountView(
view.grid.AddChild(ui.NewBordered(view.dirlist, ui.BORDER_RIGHT, acctUiConf))
}
- view.msglist = NewMessageList(aerc, view)
+ view.msglist = NewMessageList(view)
view.grid.AddChild(view.msglist).At(0, 1)
view.dirlist.OnVirtualNode(func() {
@@ -134,15 +130,15 @@ func (acct *AccountView) UpdateStatus() {
}
func (acct *AccountView) PushStatus(status string, expiry time.Duration) {
- acct.aerc.PushStatus(fmt.Sprintf("%s: %s", acct.acct.Name, status), expiry)
+ PushStatus(fmt.Sprintf("%s: %s", acct.acct.Name, status), expiry)
}
func (acct *AccountView) PushError(err error) {
- acct.aerc.PushError(fmt.Sprintf("%s: %v", acct.acct.Name, err))
+ PushError(fmt.Sprintf("%s: %v", acct.acct.Name, err))
}
func (acct *AccountView) PushWarning(warning string) {
- acct.aerc.PushWarning(fmt.Sprintf("%s: %s", acct.acct.Name, warning))
+ PushWarning(fmt.Sprintf("%s: %s", acct.acct.Name, warning))
}
func (acct *AccountView) AccountConfig() *config.AccountConfig {
@@ -226,7 +222,7 @@ func (acct *AccountView) SelectedMessagePart() *PartInfo {
}
func (acct *AccountView) isSelected() bool {
- return acct == acct.aerc.SelectedAccount()
+ return acct == SelectedAccount()
}
func (acct *AccountView) newStore(name string) *lib.MessageStore {
@@ -247,7 +243,7 @@ func (acct *AccountView) newStore(name string) *lib.MessageStore {
})
if err != nil {
msg := fmt.Sprintf("mail-received hook: %s", err)
- acct.aerc.PushError(msg)
+ PushError(msg)
}
}, func() {
if uiConf.NewMessageBell {
@@ -544,10 +540,10 @@ func (acct *AccountView) updateSplitView(msg *models.MessageInfo) {
acct.grid.RemoveChild(acct.split)
acct.split.Close()
}
- lib.NewMessageStoreView(msg, false, acct.Store(), acct.aerc.Crypto, acct.aerc.DecryptKeys,
+ lib.NewMessageStoreView(msg, false, acct.Store(), CryptoProvider(), DecryptKeys,
func(view lib.MessageView, err error) {
if err != nil {
- acct.aerc.PushError(err.Error())
+ PushError(err.Error())
return
}
acct.split = NewMessageViewer(acct, view)
diff --git a/app/aerc.go b/app/aerc.go
index a1995c2d..1170a6f2 100644
--- a/app/aerc.go
+++ b/app/aerc.go
@@ -87,10 +87,8 @@ func NewAerc(
Crypto: crypto,
}
- statusline.SetAerc(aerc)
-
for _, acct := range config.Accounts {
- view, err := NewAccountView(aerc, acct, aerc, deferLoop)
+ view, err := NewAccountView(acct, deferLoop)
if err != nil {
tabs.Add(errorScreen(err.Error()), acct.Name, nil)
} else {
@@ -100,7 +98,7 @@ func NewAerc(
}
if len(config.Accounts) == 0 {
- wizard := NewAccountWizard(aerc)
+ wizard := NewAccountWizard()
wizard.Focus(true)
aerc.NewTab(wizard, "New account")
}
@@ -732,7 +730,7 @@ func (aerc *Aerc) Mailto(addr *url.URL) error {
defer ui.Invalidate()
- composer, err := NewComposer(aerc, acct,
+ composer, err := NewComposer(acct,
acct.AccountConfig(), acct.Worker(),
config.Compose.EditHeaders, template, h, nil,
strings.NewReader(body))
@@ -775,7 +773,7 @@ func (aerc *Aerc) Mbox(source string) error {
defer ui.Invalidate()
- mboxView, err := NewAccountView(aerc, &acctConf, aerc, nil)
+ mboxView, err := NewAccountView(&acctConf, nil)
if err != nil {
aerc.NewTab(errorScreen(err.Error()), acctConf.Name)
} else {
@@ -886,9 +884,9 @@ func (aerc *Aerc) isExKey(event *tcell.EventKey, exKey config.KeyStroke) bool {
return event.Modifiers() == exKey.Modifiers && event.Key() == exKey.Key
}
-// CmdFallbackSearch checks cmds for the first executable availabe in PATH. An error is
+// cmdFallbackSearch checks cmds for the first executable availabe in PATH. An error is
// returned if none are found
-func (aerc *Aerc) CmdFallbackSearch(cmds []string) (string, error) {
+func cmdFallbackSearch(cmds []string) (string, error) {
var tried []string
for _, cmd := range cmds {
if cmd == "" {
@@ -899,7 +897,7 @@ func (aerc *Aerc) CmdFallbackSearch(cmds []string) (string, error) {
if err != nil {
tried = append(tried, cmd)
warn := fmt.Sprintf("cmd '%s' not found in PATH, using fallback", cmd)
- aerc.PushWarning(warn)
+ PushWarning(warn)
continue
}
return cmd, nil
diff --git a/app/app.go b/app/app.go
new file mode 100644
index 00000000..80f940a3
--- /dev/null
+++ b/app/app.go
@@ -0,0 +1,80 @@
+package app
+
+import (
+ "time"
+
+ "git.sr.ht/~rjarry/aerc/config"
+ "git.sr.ht/~rjarry/aerc/lib"
+ "git.sr.ht/~rjarry/aerc/lib/crypto"
+ "git.sr.ht/~rjarry/aerc/lib/ipc"
+ "git.sr.ht/~rjarry/aerc/lib/ui"
+ "git.sr.ht/~rjarry/aerc/models"
+ "git.sr.ht/~rjarry/aerc/worker/types"
+ "github.com/ProtonMail/go-crypto/openpgp"
+)
+
+var aerc *Aerc
+
+func Init(
+ crypto crypto.Provider,
+ cmd func([]string, *config.AccountConfig, *models.MessageInfo) error,
+ complete func(cmd string) ([]string, string), history lib.History,
+ deferLoop chan struct{},
+) {
+ aerc = NewAerc(crypto, cmd, complete, history, deferLoop)
+}
+
+func Drawable() ui.DrawableInteractive { return aerc }
+func IPCHandler() ipc.Handler { return aerc }
+func HandleMessage(msg types.WorkerMessage) { aerc.HandleMessage(msg) }
+
+func CloseBackends() error { return aerc.CloseBackends() }
+
+func AddDialog(d ui.DrawableInteractive) { aerc.AddDialog(d) }
+func CloseDialog() { aerc.CloseDialog() }
+
+func HumanReadableBindings() []string {
+ return aerc.HumanReadableBindings()
+}
+
+func Account(name string) (*AccountView, error) { return aerc.Account(name) }
+func AccountNames() []string { return aerc.AccountNames() }
+func NextAccount() (*AccountView, error) { return aerc.NextAccount() }
+func PrevAccount() (*AccountView, error) { return aerc.PrevAccount() }
+func SelectedAccount() *AccountView { return aerc.SelectedAccount() }
+func SelectedAccountUiConfig() *config.UIConfig { return aerc.SelectedAccountUiConfig() }
+
+func NextTab() { aerc.NextTab() }
+func PrevTab() { aerc.PrevTab() }
+func PinTab() { aerc.PinTab() }
+func UnpinTab() { aerc.UnpinTab() }
+func MoveTab(i int, relative bool) { aerc.MoveTab(i, relative) }
+func TabNames() []string { return aerc.TabNames() }
+func SelectTab(name string) bool { return aerc.SelectTab(name) }
+func SelectPreviousTab() bool { return aerc.SelectPreviousTab() }
+func SelectedTab() *ui.Tab { return aerc.SelectedTab() }
+func SelectedTabContent() ui.Drawable { return aerc.SelectedTabContent() }
+func SelectTabIndex(index int) bool { return aerc.SelectTabIndex(index) }
+func RemoveTab(tab ui.Drawable, closeContent bool) { aerc.RemoveTab(tab, closeContent) }
+func NewTab(clickable ui.Drawable, name string) *ui.Tab { return aerc.NewTab(clickable, name) }
+func ReplaceTab(tabSrc ui.Drawable, tabTarget ui.Drawable, name string, closeSrc bool) {
+ aerc.ReplaceTab(tabSrc, tabTarget, name, closeSrc)
+}
+
+func UpdateStatus() { aerc.UpdateStatus() }
+func PushPrompt(prompt *ExLine) { aerc.PushPrompt(prompt) }
+func SetError(text string) { aerc.SetError(text) }
+func PushError(text string) *StatusMessage { return aerc.PushError(text) }
+func PushWarning(text string) *StatusMessage { return aerc.PushWarning(text) }
+func PushSuccess(text string) *StatusMessage { return aerc.PushSuccess(text) }
+func PushStatus(text string, expiry time.Duration) *StatusMessage {
+ return aerc.PushStatus(text, expiry)
+}
+
+func RegisterChoices(choices []Choice) { aerc.RegisterChoices(choices) }
+func RegisterPrompt(prompt string, cmd []string) { aerc.RegisterPrompt(prompt, cmd) }
+
+func CryptoProvider() crypto.Provider { return aerc.Crypto }
+func DecryptKeys(keys []openpgp.Key, symmetric bool) (b []byte, err error) {
+ return aerc.DecryptKeys(keys, symmetric)
+}
diff --git a/app/compose.go b/app/compose.go
index 6eda2b0d..546184d8 100644
--- a/app/compose.go
+++ b/app/compose.go
@@ -41,7 +41,6 @@ type Composer struct {
acctConfig *config.AccountConfig
acct *AccountView
- aerc *Aerc
attachments []lib.Attachment
editor *Terminal
@@ -75,7 +74,7 @@ type Composer struct {
}
func NewComposer(
- aerc *Aerc, acct *AccountView, acctConfig *config.AccountConfig,
+ acct *AccountView, acctConfig *config.AccountConfig,
worker *types.Worker, editHeaders bool, template string,
h *mail.Header, orig *models.OriginalMail, body io.Reader,
) (*Composer, error) {
@@ -92,7 +91,6 @@ func NewComposer(
c := &Composer{
acct: acct,
acctConfig: acctConfig,
- aerc: aerc,
header: h,
parent: orig,
email: email,
@@ -178,7 +176,7 @@ func (c *Composer) setupFor(view *AccountView) error {
cmd = config.Compose.AddressBookCmd
}
cmpl := completer.New(cmd, func(err error) {
- c.aerc.PushError(
+ PushError(
fmt.Sprintf("could not complete header: %v", err))
log.Errorf("could not complete header: %v", err)
})
@@ -192,7 +190,7 @@ func (c *Composer) setupFor(view *AccountView) error {
}
// rebuild editors and focusable slice
- c.buildComposeHeader(c.aerc, cmpl)
+ c.buildComposeHeader(cmpl)
// restore the editor in the focusable list
if focusEditor != nil {
@@ -224,7 +222,7 @@ func (c *Composer) setupFor(view *AccountView) error {
return nil
}
-func (c *Composer) buildComposeHeader(aerc *Aerc, cmpl *completer.Completer) {
+func (c *Composer) buildComposeHeader(cmpl *completer.Completer) {
c.layout = config.Compose.HeaderLayout
c.editors = make(map[string]*headerEditor)
c.focusable = make([]ui.MouseableDrawableInteractive, 0)
@@ -351,13 +349,13 @@ func (c *Composer) SetAttachKey(attach bool) error {
} else {
s = c.acctConfig.From.Address
}
- c.crypto.signKey, err = c.aerc.Crypto.GetSignerKeyId(s)
+ c.crypto.signKey, err = CryptoProvider().GetSignerKeyId(s)
if err != nil {
return err
}
}
- r, err := c.aerc.Crypto.ExportKey(c.crypto.signKey)
+ r, err := CryptoProvider().ExportKey(c.crypto.signKey)
if err != nil {
return err
}
@@ -435,7 +433,7 @@ func (c *Composer) updateCrypto() error {
c.crypto = newCryptoStatus(uiConfig)
}
if c.sign {
- cp := c.aerc.Crypto
+ cp := CryptoProvider()
s, err := c.Signer()
if err != nil {
return errors.Wrap(err, "Signer")
@@ -685,7 +683,7 @@ func (c *Composer) readSignatureFromFile() []byte {
sigFile = xdg.ExpandHome(sigFile)
signature, err := os.ReadFile(sigFile)
if err != nil {
- c.aerc.PushError(
+ PushError(
fmt.Sprintf(" Error loading signature from file: %v", sigFile))
return nil
}
@@ -1026,12 +1024,12 @@ func (c *Composer) WriteMessage(header *mail.Header, writer io.Writer) error {
if err != nil {
return err
}
- cleartext, err = c.aerc.Crypto.Encrypt(&buf, rcpts, signer, c.aerc.DecryptKeys, header)
+ cleartext, err = CryptoProvider().Encrypt(&buf, rcpts, signer, DecryptKeys, header)
if err != nil {
return err
}
} else {
- cleartext, err = c.aerc.Crypto.Sign(&buf, signer, c.aerc.DecryptKeys, header)
+ cleartext, err = CryptoProvider().Sign(&buf, signer, DecryptKeys, header)
if err != nil {
return err
}
@@ -1235,7 +1233,7 @@ func (c *Composer) termClosed(err error) {
return
}
if e := c.reopenEmailFile(); e != nil {
- c.aerc.PushError("Failed to reopen email file: " + e.Error())
+ PushError("Failed to reopen email file: " + e.Error())
}
editor := c.editor
defer editor.Destroy()
@@ -1247,8 +1245,8 @@ func (c *Composer) termClosed(err error) {
if editor.cmd.ProcessState.ExitCode() > 0 {
c.Close()
- c.aerc.RemoveTab(c, true)
- c.aerc.PushError("Editor exited with error. Compose aborted!")
+ RemoveTab(c, true)
+ PushError("Editor exited with error. Compose aborted!")
return
}
@@ -1256,12 +1254,12 @@ func (c *Composer) termClosed(err error) {
// parse embedded header when editor is closed
embedHeader, err := c.parseEmbeddedHeader()
if err != nil {
- c.aerc.PushError(err.Error())
+ PushError(err.Error())
err := c.showTerminal()
if err != nil {
c.Close()
- c.aerc.RemoveTab(c, true)
- c.aerc.PushError(err.Error())
+ RemoveTab(c, true)
+ PushError(err.Error())
}
return
}
@@ -1311,7 +1309,7 @@ func (c *Composer) showTerminal() error {
"vi",
"nano",
}
- editorName, err := c.aerc.CmdFallbackSearch(cmds)
+ editorName, err := cmdFallbackSearch(cmds)
if err != nil {
c.acct.PushError(fmt.Errorf("could not start editor: %w", err))
}
@@ -1900,12 +1898,12 @@ func (c *Composer) checkEncryptionKeys(_ string) bool {
// explicitly call c.SetEncrypt(false) when encryption is not possible
c.SetEncrypt(false)
st := fmt.Sprintf("Cannot encrypt: %v", err)
- c.aerc.statusline.PushError(st)
+ aerc.statusline.PushError(st)
return false
}
var mk []string
for _, rcpt := range rcpts {
- key, err := c.aerc.Crypto.GetKeyId(rcpt)
+ key, err := CryptoProvider().GetKeyId(rcpt)
if err != nil || key == "" {
mk = append(mk, rcpt)
}
@@ -1919,7 +1917,7 @@ func (c *Composer) checkEncryptionKeys(_ string) bool {
if c.Config().PgpOpportunisticEncrypt {
switch c.Config().PgpErrorLevel {
case config.PgpErrorLevelWarn:
- c.aerc.statusline.PushWarning(st)
+ aerc.statusline.PushWarning(st)
return false
case config.PgpErrorLevelNone:
return false
@@ -1927,7 +1925,7 @@ func (c *Composer) checkEncryptionKeys(_ string) bool {
// Continue to the default
}
}
- c.aerc.statusline.PushError(st)
+ PushError(st)
encrypt = false
case len(rcpts) == 0:
encrypt = false
diff --git a/app/msglist.go b/app/msglist.go
index 57771ae8..b60ae148 100644
--- a/app/msglist.go
+++ b/app/msglist.go
@@ -27,14 +27,12 @@ type MessageList struct {
spinner *Spinner
store *lib.MessageStore
isInitalizing bool
- aerc *Aerc
}
-func NewMessageList(aerc *Aerc, account *AccountView) *MessageList {
+func NewMessageList(account *AccountView) *MessageList {
ml := &MessageList{
spinner: NewSpinner(account.uiConf),
isInitalizing: true,
- aerc: aerc,
}
// TODO: stop spinner, probably
ml.spinner.Start()
@@ -56,11 +54,11 @@ type messageRowParams struct {
func (ml *MessageList) Draw(ctx *ui.Context) {
ml.height = ctx.Height()
ml.width = ctx.Width()
- uiConfig := ml.aerc.SelectedAccountUiConfig()
+ uiConfig := SelectedAccountUiConfig()
ctx.Fill(0, 0, ctx.Width(), ctx.Height(), ' ',
uiConfig.GetStyle(config.STYLE_MSGLIST_DEFAULT))
- acct := ml.aerc.SelectedAccount()
+ acct := SelectedAccount()
store := ml.Store()
if store == nil || acct == nil || len(store.Uids()) == 0 {
if ml.isInitalizing {
@@ -242,7 +240,7 @@ func addMessage(
}
func (ml *MessageList) drawScrollbar(ctx *ui.Context) {
- uiConfig := ml.aerc.SelectedAccountUiConfig()
+ uiConfig := SelectedAccountUiConfig()
gutterStyle := uiConfig.GetStyle(config.STYLE_MSGLIST_GUTTER)
pillStyle := uiConfig.GetStyle(config.STYLE_MSGLIST_PILL)
@@ -259,13 +257,13 @@ func (ml *MessageList) MouseEvent(localX int, localY int, event tcell.Event) {
if event, ok := event.(*tcell.EventMouse); ok {
switch event.Buttons() {
case tcell.Button1:
- if ml.aerc == nil {
+ if aerc == nil {
return
}
selectedMsg, ok := ml.Clicked(localX, localY)
if ok {
ml.Select(selectedMsg)
- acct := ml.aerc.SelectedAccount()
+ acct := SelectedAccount()
if acct == nil || acct.Messages().Empty() {
return
}
@@ -275,14 +273,14 @@ func (ml *MessageList) MouseEvent(localX int, localY int, event tcell.Event) {
return
}
lib.NewMessageStoreView(msg, acct.UiConfig().AutoMarkRead,
- store, ml.aerc.Crypto, ml.aerc.DecryptKeys,
+ store, CryptoProvider(), DecryptKeys,
func(view lib.MessageView, err error) {
if err != nil {
- ml.aerc.PushError(err.Error())
+ PushError(err.Error())
return
}
viewer := NewMessageViewer(acct, view)
- ml.aerc.NewTab(viewer, msg.Envelope.Subject)
+ NewTab(viewer, msg.Envelope.Subject)
})
}
case tcell.WheelDown:
@@ -391,7 +389,7 @@ func (ml *MessageList) Select(index int) {
}
func (ml *MessageList) drawEmptyMessage(ctx *ui.Context) {
- uiConfig := ml.aerc.SelectedAccountUiConfig()
+ uiConfig := SelectedAccountUiConfig()
msg := uiConfig.EmptyMessage
ctx.Printf((ctx.Width()/2)-(len(msg)/2), 0,
uiConfig.GetStyle(config.STYLE_MSGLIST_DEFAULT), "%s", msg)
diff --git a/app/msgviewer.go b/app/msgviewer.go
index 2d261c3f..5da37552 100644
--- a/app/msgviewer.go
+++ b/app/msgviewer.go
@@ -563,7 +563,7 @@ func NewPartViewer(
os.Getenv("PAGER"),
"less -Rc",
}
- pagerCmd, err := acct.aerc.CmdFallbackSearch(cmds)
+ pagerCmd, err := cmdFallbackSearch(cmds)
if err != nil {
acct.PushError(fmt.Errorf("could not start pager: %w", err))
return nil, err
diff --git a/app/status.go b/app/status.go
index f6919e29..fdeede19 100644
--- a/app/status.go
+++ b/app/status.go
@@ -18,7 +18,6 @@ import (
type StatusLine struct {
sync.Mutex
stack []*StatusMessage
- aerc *Aerc
acct *AccountView
err string
}
@@ -48,9 +47,9 @@ func (status *StatusLine) Draw(ctx *ui.Context) {
msg = runewidth.FillRight(msg, ctx.Width())
style := status.uiConfig().GetStyle(config.STYLE_STATUSLINE_ERROR)
ctx.Printf(0, 0, style, "%s", msg)
- case status.aerc != nil && status.acct != nil:
+ case aerc != nil && status.acct != nil:
data := state.NewDataSetter()
- data.SetPendingKeys(status.aerc.pendingKeys)
+ data.SetPendingKeys(aerc.pendingKeys)
data.SetState(&status.acct.state)
data.SetAccount(status.acct.acct)
data.SetFolder(status.acct.Directories().SelectedDirectory())
@@ -154,11 +153,7 @@ func (status *StatusLine) Expire() {
}
func (status *StatusLine) uiConfig() *config.UIConfig {
- return status.aerc.SelectedAccountUiConfig()
-}
-
-func (status *StatusLine) SetAerc(aerc *Aerc) {
- status.aerc = aerc
+ return SelectedAccountUiConfig()
}
func (msg *StatusMessage) Color(style tcell.Style) {