diff options
author | Chris Vittal <chris@vittal.dev> | 2020-10-27 14:56:44 -0400 |
---|---|---|
committer | Reto Brunner <reto@labrat.space> | 2020-11-01 09:50:58 +0100 |
commit | f9bba3d17d4ac8c12e01adccc06566a46546e995 (patch) | |
tree | 3d96a7e74f668739544ffe45b70cc96696dd4f99 /widgets | |
parent | 743683a0c19c75ba87d65b6d0c9be117d0224a3e (diff) | |
download | aerc-f9bba3d17d4ac8c12e01adccc06566a46546e995.tar.gz |
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.
Diffstat (limited to 'widgets')
-rw-r--r-- | widgets/msglist.go | 27 |
1 files changed, 14 insertions, 13 deletions
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) |