aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/msglist.go
diff options
context:
space:
mode:
authorReto Brunner <reto@labrat.space>2020-05-27 07:37:02 +0200
committerReto Brunner <reto@labrat.space>2020-05-27 07:57:10 +0200
commit0f78f06610c0e8887aba2ae50e99b86477a384b3 (patch)
treeff4cd6581d3af0911954a37550602366d2bb0e2f /widgets/msglist.go
parent6c4ed3cfe2fe66a1e5f26c404ea90e048142db72 (diff)
downloadaerc-0f78f06610c0e8887aba2ae50e99b86477a384b3.tar.gz
Add Style configuration
The following functionalities are added to configure aerc ui styles. - Read stylesets from file with very basic fnmatch wildcard matching - Add default styleset - Support different stylesets as part of UiConfig allowing contextual styles. - Move widgets/ui elements to use the stylesets. - Add configuration manual for the styleset
Diffstat (limited to 'widgets/msglist.go')
-rw-r--r--widgets/msglist.go55
1 files changed, 37 insertions, 18 deletions
diff --git a/widgets/msglist.go b/widgets/msglist.go
index 5aedb446..5d12f8e3 100644
--- a/widgets/msglist.go
+++ b/widgets/msglist.go
@@ -3,6 +3,7 @@ package widgets
import (
"fmt"
"log"
+ "time"
"github.com/gdamore/tcell"
"github.com/mattn/go-runewidth"
@@ -49,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 {
@@ -84,34 +86,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
+ flaged := false
for _, flag := range msg.Flags {
- if flag == models.SeenFlag {
+ switch flag {
+ case models.SeenFlag:
seen = true
+ case models.FlaggedFlag:
+ flaged = true
}
}
if !seen {
- style = style.Bold(true)
+ so = config.STYLE_MSGLIST_UNREAD
}
- ctx.Fill(0, row, ctx.Width(), 1, ' ', style)
- 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,
- })
+ if flaged {
+ so = config.STYLE_MSGLIST_FLAGGED
+ }
+
+ // marked message
+ if store.IsMarked(msg.Uid) {
+ so = config.STYLE_MSGLIST_MARKED
+ }
+ style := uiConfig.GetStyle(so)
+
+ // current row
+ if row == ml.store.SelectedIndex()-ml.scroll {
+ style = uiConfig.GetStyleSelected(so)
+ }
+
+ ctx.Fill(0, row, ctx.Width(), 1, ' ', style)
fmtStr, args, err := format.ParseMessageFormat(
ml.aerc.SelectedAccount().acct.From,
uiConfig.IndexFormat,
@@ -168,7 +186,7 @@ func (ml *MessageList) MouseEvent(localX int, localY int, event tcell.Event) {
lib.NewMessageStoreView(msg, store, ml.aerc.DecryptKeys,
func(view lib.MessageView, err error) {
if err != nil {
- ml.aerc.PushError(err.Error())
+ ml.aerc.PushError(err.Error(), 10*time.Second)
return
}
viewer := NewMessageViewer(acct, ml.aerc.Config(), view)
@@ -288,7 +306,8 @@ func (ml *MessageList) Scroll() {
}
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)
}