diff options
Diffstat (limited to 'widgets')
-rw-r--r-- | widgets/account.go | 23 | ||||
-rw-r--r-- | widgets/msglist.go | 12 | ||||
-rw-r--r-- | widgets/msgviewer.go | 2 |
3 files changed, 27 insertions, 10 deletions
diff --git a/widgets/account.go b/widgets/account.go index 404a9eaf..66320a3c 100644 --- a/widgets/account.go +++ b/widgets/account.go @@ -31,13 +31,24 @@ type AccountView struct { worker *types.Worker } +func (acct *AccountView) UiConfig() config.UIConfig { + return acct.conf.GetUiConfig(map[int]string{ + config.UI_CONTEXT_ACCOUNT: acct.AccountConfig().Name, + config.UI_CONTEXT_FOLDER: acct.Directories().Selected(), + }) +} + func NewAccountView(aerc *Aerc, conf *config.AercConfig, acct *config.AccountConfig, logger *log.Logger, host TabHost) *AccountView { + acctUiConf := conf.GetUiConfig(map[int]string{ + config.UI_CONTEXT_ACCOUNT: acct.Name, + }) + grid := ui.NewGrid().Rows([]ui.GridSpec{ {ui.SIZE_WEIGHT, 1}, }).Columns([]ui.GridSpec{ - {ui.SIZE_EXACT, conf.Ui.SidebarWidth}, + {ui.SIZE_EXACT, acctUiConf.SidebarWidth}, {ui.SIZE_WEIGHT, 1}, }) @@ -54,8 +65,8 @@ func NewAccountView(aerc *Aerc, conf *config.AercConfig, acct *config.AccountCon } } - dirlist := NewDirectoryList(acct, &conf.Ui, logger, worker) - if conf.Ui.SidebarWidth > 0 { + dirlist := NewDirectoryList(acct, &acctUiConf, logger, worker) + if acctUiConf.SidebarWidth > 0 { grid.AddChild(ui.NewBordered(dirlist, ui.BORDER_RIGHT)) } @@ -236,7 +247,7 @@ func (acct *AccountView) onMessage(msg types.WorkerMessage) { acct.conf.Triggers.ExecNewEmail(acct.acct, acct.conf, msg) }, func() { - if acct.conf.Ui.NewMessageBell { + if acct.UiConfig().NewMessageBell { acct.host.Beep() } }) @@ -272,10 +283,10 @@ func (acct *AccountView) onMessage(msg types.WorkerMessage) { } func (acct *AccountView) getSortCriteria() []*types.SortCriterion { - if len(acct.conf.Ui.Sort) == 0 { + if len(acct.UiConfig().Sort) == 0 { return nil } - criteria, err := sort.GetSortCriteria(acct.conf.Ui.Sort) + criteria, err := sort.GetSortCriteria(acct.UiConfig().Sort) if err != nil { acct.aerc.PushError(" ui.sort: " + err.Error()) return nil diff --git a/widgets/msglist.go b/widgets/msglist.go index 243c5dbc..24a99404 100644 --- a/widgets/msglist.go +++ b/widgets/msglist.go @@ -106,10 +106,16 @@ func (ml *MessageList) Draw(ctx *ui.Context) { } ctx.Fill(0, row, ctx.Width(), 1, ' ', style) + uiConfig := ml.conf.GetUiConfig(map[int]string{ + config.UI_CONTEXT_ACCOUNT: ml.aerc.SelectedAccount().AccountConfig().Name, + config.UI_CONTEXT_FOLDER: ml.aerc.SelectedAccount().Directories().Selected(), + config.UI_CONTEXT_SUBJECT: msg.Envelope.Subject, + }) + fmtStr, args, err := format.ParseMessageFormat( ml.aerc.SelectedAccount().acct.From, - ml.conf.Ui.IndexFormat, - ml.conf.Ui.TimestampFormat, "", i, msg, store.IsMarked(uid)) + uiConfig.IndexFormat, + uiConfig.TimestampFormat, "", i, msg, store.IsMarked(uid)) if err != nil { ctx.Printf(0, row, style, "%v", err) } else { @@ -265,7 +271,7 @@ func (ml *MessageList) Scroll() { } func (ml *MessageList) drawEmptyMessage(ctx *ui.Context) { - msg := ml.conf.Ui.EmptyMessage + msg := ml.aerc.SelectedAccount().UiConfig().EmptyMessage ctx.Printf((ctx.Width()/2)-(len(msg)/2), 0, tcell.StyleDefault, "%s", msg) } diff --git a/widgets/msgviewer.go b/widgets/msgviewer.go index 0bfd2d85..93d3d89e 100644 --- a/widgets/msgviewer.go +++ b/widgets/msgviewer.go @@ -63,7 +63,7 @@ func NewMessageViewer(acct *AccountView, conf *config.AercConfig, func(header string) ui.Drawable { return &HeaderView{ Name: header, - Value: fmtHeader(msg, header, conf.Ui.TimestampFormat), + Value: fmtHeader(msg, header, acct.UiConfig().TimestampFormat), } }, ) |