From f9bba3d17d4ac8c12e01adccc06566a46546e995 Mon Sep 17 00:00:00 2001 From: Chris Vittal Date: Tue, 27 Oct 2020 14:56:44 -0400 Subject: Apply relevant msglist styles in order Allow styles to be layered over a base style. The list of styles to apply is layered over the base style in order, such that if the layer does not differ from the base it is not used. The order that these styles are applied in is, from first to last: msglist_default msglist_unread msglist_read (exclusive with unread, so technically the same level) msglist_flagged msglist_deleted msglist_marked So, msglist_marked style dominates. This fixes an issue where the msglist_deleted style was not being applied. --- widgets/msglist.go | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'widgets') diff --git a/widgets/msglist.go b/widgets/msglist.go index b7c10d7..61738a8 100644 --- a/widgets/msglist.go +++ b/widgets/msglist.go @@ -108,12 +108,7 @@ func (ml *MessageList) Draw(ctx *ui.Context) { config.UI_CONTEXT_SUBJECT: msg.Envelope.Subject, }) - so := config.STYLE_MSGLIST_DEFAULT - - // deleted message - if _, ok := store.Deleted[msg.Uid]; ok { - so = config.STYLE_MSGLIST_DELETED - } + msg_styles := []config.StyleObject{} // unread message seen := false flagged := false @@ -127,25 +122,31 @@ func (ml *MessageList) Draw(ctx *ui.Context) { } if seen { - so = config.STYLE_MSGLIST_READ + msg_styles = append(msg_styles, config.STYLE_MSGLIST_READ) } else { - so = config.STYLE_MSGLIST_UNREAD + msg_styles = append(msg_styles, config.STYLE_MSGLIST_UNREAD) } if flagged { - so = config.STYLE_MSGLIST_FLAGGED + msg_styles = append(msg_styles, config.STYLE_MSGLIST_FLAGGED) + } + + // deleted message + if _, ok := store.Deleted[msg.Uid]; ok { + msg_styles = append(msg_styles, config.STYLE_MSGLIST_DELETED) } // marked message if store.IsMarked(msg.Uid) { - so = config.STYLE_MSGLIST_MARKED + msg_styles = append(msg_styles, config.STYLE_MSGLIST_MARKED) } - style := uiConfig.GetStyle(so) - + var style tcell.Style // current row if row == ml.store.SelectedIndex()-ml.scroll { - style = uiConfig.GetStyleSelected(so) + style = uiConfig.GetComposedStyleSelected(config.STYLE_MSGLIST_DEFAULT, msg_styles) + } else { + style = uiConfig.GetComposedStyle(config.STYLE_MSGLIST_DEFAULT, msg_styles) } ctx.Fill(0, row, ctx.Width(), 1, ' ', style) -- cgit 1.4.1-2-gfad0