summaryrefslogtreecommitdiff
path: root/widgets/msglist.go
diff options
context:
space:
mode:
authorKalyan Sriram <coder.kalyan@gmail.com>2020-07-27 01:03:55 -0700
committerReto Brunner <reto@labrat.space>2020-07-30 19:35:59 +0200
commit1ff687ca2b0821c2cacc1fa725abb3302d2af9da (patch)
treeb84df04a645c1fd2ee94d7a08f2f9c717930e9ab /widgets/msglist.go
parent1bab1754f095a5c0537fc639d0214f6efbb340a2 (diff)
downloadaerc-1ff687ca2b0821c2cacc1fa725abb3302d2af9da.zip
Implement style configuration.
Introduce the ability to configure stylesets, allowing customization of aerc's look (color scheme, font weight, etc). Default styleset is installed to /path/to/aerc/stylesets/default.
Diffstat (limited to 'widgets/msglist.go')
-rw-r--r--widgets/msglist.go50
1 files changed, 32 insertions, 18 deletions
diff --git a/widgets/msglist.go b/widgets/msglist.go
index 1ed6bb1..e38dd9e 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)
}