aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/account.go5
-rw-r--r--app/aerc.go28
-rw-r--r--app/app.go8
-rw-r--r--app/msglist.go3
-rw-r--r--app/status.go2
-rw-r--r--app/tabhost.go15
6 files changed, 19 insertions, 42 deletions
diff --git a/app/account.go b/app/account.go
index bcb5028a..c7abde6f 100644
--- a/app/account.go
+++ b/app/account.go
@@ -31,7 +31,6 @@ type AccountView struct {
dirlist DirectoryLister
labels []string
grid *ui.Grid
- host TabHost
tab *ui.Tab
msglist *MessageList
worker *types.Worker
@@ -125,7 +124,7 @@ func (acct *AccountView) SetStatus(setters ...state.SetStateFunc) {
func (acct *AccountView) UpdateStatus() {
if acct.isSelected() {
- acct.host.UpdateStatus()
+ UpdateStatus()
}
}
@@ -247,7 +246,7 @@ func (acct *AccountView) newStore(name string) *lib.MessageStore {
}
}, func() {
if uiConf.NewMessageBell {
- acct.host.Beep()
+ aerc.Beep()
}
},
acct.updateSplitView,
diff --git a/app/aerc.go b/app/aerc.go
index 1170a6f2..21430f80 100644
--- a/app/aerc.go
+++ b/app/aerc.go
@@ -51,12 +51,12 @@ type Choice struct {
Command []string
}
-func NewAerc(
+func (aerc *Aerc) Init(
crypto crypto.Provider,
cmd func([]string, *config.AccountConfig, *models.MessageInfo) error,
complete func(cmd string) ([]string, string), cmdHistory lib.History,
deferLoop chan struct{},
-) *Aerc {
+) {
tabs := ui.NewTabs(config.Ui)
statusbar := ui.NewStack(config.Ui)
@@ -74,18 +74,16 @@ func NewAerc(
grid.AddChild(tabs.TabContent).At(1, 0)
grid.AddChild(statusbar).At(2, 0)
- aerc := &Aerc{
- accounts: make(map[string]*AccountView),
- cmd: cmd,
- cmdHistory: cmdHistory,
- complete: complete,
- grid: grid,
- statusbar: statusbar,
- statusline: statusline,
- prompts: ui.NewStack(config.Ui),
- tabs: tabs,
- Crypto: crypto,
- }
+ aerc.accounts = make(map[string]*AccountView)
+ aerc.cmd = cmd
+ aerc.cmdHistory = cmdHistory
+ aerc.complete = complete
+ aerc.grid = grid
+ aerc.statusbar = statusbar
+ aerc.statusline = statusline
+ aerc.prompts = ui.NewStack(config.Ui)
+ aerc.tabs = tabs
+ aerc.Crypto = crypto
for _, acct := range config.Accounts {
view, err := NewAccountView(acct, deferLoop)
@@ -121,8 +119,6 @@ func NewAerc(
}
aerc.showConfigWarnings()
-
- return aerc
}
func (aerc *Aerc) showConfigWarnings() {
diff --git a/app/app.go b/app/app.go
index 80f940a3..73459cb8 100644
--- a/app/app.go
+++ b/app/app.go
@@ -13,7 +13,7 @@ import (
"github.com/ProtonMail/go-crypto/openpgp"
)
-var aerc *Aerc
+var aerc Aerc
func Init(
crypto crypto.Provider,
@@ -21,11 +21,11 @@ func Init(
complete func(cmd string) ([]string, string), history lib.History,
deferLoop chan struct{},
) {
- aerc = NewAerc(crypto, cmd, complete, history, deferLoop)
+ aerc.Init(crypto, cmd, complete, history, deferLoop)
}
-func Drawable() ui.DrawableInteractive { return aerc }
-func IPCHandler() ipc.Handler { return aerc }
+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() }
diff --git a/app/msglist.go b/app/msglist.go
index b60ae148..e57bfe9d 100644
--- a/app/msglist.go
+++ b/app/msglist.go
@@ -257,9 +257,6 @@ 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 aerc == nil {
- return
- }
selectedMsg, ok := ml.Clicked(localX, localY)
if ok {
ml.Select(selectedMsg)
diff --git a/app/status.go b/app/status.go
index fdeede19..dbedea7e 100644
--- a/app/status.go
+++ b/app/status.go
@@ -47,7 +47,7 @@ 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 aerc != nil && status.acct != nil:
+ case status.acct != nil:
data := state.NewDataSetter()
data.SetPendingKeys(aerc.pendingKeys)
data.SetState(&status.acct.state)
diff --git a/app/tabhost.go b/app/tabhost.go
deleted file mode 100644
index 9a206084..00000000
--- a/app/tabhost.go
+++ /dev/null
@@ -1,15 +0,0 @@
-package app
-
-import (
- "time"
-)
-
-type TabHost interface {
- BeginExCommand(cmd string)
- UpdateStatus()
- SetError(err string)
- PushStatus(text string, expiry time.Duration) *StatusMessage
- PushError(text string) *StatusMessage
- PushSuccess(text string) *StatusMessage
- Beep()
-}