diff options
Diffstat (limited to 'widgets/msglist.go')
-rw-r--r-- | widgets/msglist.go | 50 |
1 files changed, 32 insertions, 18 deletions
diff --git a/widgets/msglist.go b/widgets/msglist.go index 1ed6bb15..e38dd9e6 100644 --- a/widgets/msglist.go +++ b/widgets/msglist.go @@ -50,7 +50,8 @@ func (ml *MessageList) Invalidate() { func (ml *MessageList) Draw(ctx *ui.Context) { ml.height = ctx.Height() - ctx.Fill(0, 0, ctx.Width(), ctx.Height(), ' ', tcell.StyleDefault) + ctx.Fill(0, 0, ctx.Width(), ctx.Height(), ' ', + ml.aerc.SelectedAccount().UiConfig().GetStyle(config.STYLE_MSGLIST_DEFAULT)) store := ml.Store() if store == nil { @@ -101,38 +102,50 @@ func (ml *MessageList) Draw(ctx *ui.Context) { continue } - style := tcell.StyleDefault + uiConfig := ml.conf.GetUiConfig(map[config.ContextType]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, + }) + + so := config.STYLE_MSGLIST_DEFAULT - // current row - if row == ml.store.SelectedIndex()-ml.scroll { - style = style.Reverse(true) - } // deleted message if _, ok := store.Deleted[msg.Uid]; ok { - style = style.Foreground(tcell.ColorGray) + so = config.STYLE_MSGLIST_DELETED } // unread message seen := false + flagged := false for _, flag := range msg.Flags { - if flag == models.SeenFlag { + switch flag { + case models.SeenFlag: seen = true + case models.FlaggedFlag: + flagged = true } } if !seen { - style = style.Bold(true) + so = config.STYLE_MSGLIST_UNREAD } - ctx.Fill(0, row, textWidth, 1, ' ', style) + if flagged { + so = config.STYLE_MSGLIST_FLAGGED + } - confParams := map[config.ContextType]string{ - config.UI_CONTEXT_ACCOUNT: ml.aerc.SelectedAccount().AccountConfig().Name, - config.UI_CONTEXT_FOLDER: ml.aerc.SelectedAccount().Directories().Selected(), + // marked message + if store.IsMarked(msg.Uid) { + so = config.STYLE_MSGLIST_MARKED } - if msg.Envelope != nil { - confParams[config.UI_CONTEXT_SUBJECT] = msg.Envelope.Subject + + style := uiConfig.GetStyle(so) + + // current row + if row == ml.store.SelectedIndex()-ml.scroll { + style = uiConfig.GetStyleSelected(so) } - uiConfig := ml.conf.GetUiConfig(confParams) + ctx.Fill(0, row, ctx.Width(), 1, ' ', style) fmtStr, args, err := format.ParseMessageFormat( ml.aerc.SelectedAccount().acct.From, uiConfig.IndexFormat, @@ -342,7 +355,8 @@ func (ml *MessageList) ensureScroll() { } func (ml *MessageList) drawEmptyMessage(ctx *ui.Context) { - msg := ml.aerc.SelectedAccount().UiConfig().EmptyMessage + uiConfig := ml.aerc.SelectedAccount().UiConfig() + msg := uiConfig.EmptyMessage ctx.Printf((ctx.Width()/2)-(len(msg)/2), 0, - tcell.StyleDefault, "%s", msg) + uiConfig.GetStyle(config.STYLE_MSGLIST_DEFAULT), "%s", msg) } |