msglist: use distinct style for unread emails
This commit is contained in:
parent
06e1b45a78
commit
5f651b32e5
2 changed files with 20 additions and 5 deletions
|
@ -171,16 +171,16 @@ func ParseIndexFormat(conf *config.AercConfig, number int,
|
||||||
var delFlag = ""
|
var delFlag = ""
|
||||||
var flaggedFlag = ""
|
var flaggedFlag = ""
|
||||||
for _, flag := range msg.Flags {
|
for _, flag := range msg.Flags {
|
||||||
if flag == "\\Seen" {
|
if flag == imap.SeenFlag {
|
||||||
readFlag = "O" // message is old
|
readFlag = "O" // message is old
|
||||||
} else if flag == "\\Recent" {
|
} else if flag == imap.RecentFlag {
|
||||||
readFlag = "N" // message is new
|
readFlag = "N" // message is new
|
||||||
} else if flag == "\\Answered" {
|
} else if flag == imap.AnsweredFlag {
|
||||||
readFlag = "r" // message has been replied to
|
readFlag = "r" // message has been replied to
|
||||||
} else if flag == "\\Deleted" {
|
} else if flag == imap.DeletedFlag {
|
||||||
delFlag = "D"
|
delFlag = "D"
|
||||||
// TODO: check if attachments
|
// TODO: check if attachments
|
||||||
} else if flag == "\\Flagged" {
|
} else if flag == imap.FlaggedFlag {
|
||||||
flaggedFlag = "!"
|
flaggedFlag = "!"
|
||||||
}
|
}
|
||||||
// TODO: check gpg stuff
|
// TODO: check gpg stuff
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
|
"github.com/emersion/go-imap"
|
||||||
"github.com/gdamore/tcell"
|
"github.com/gdamore/tcell"
|
||||||
"github.com/mattn/go-runewidth"
|
"github.com/mattn/go-runewidth"
|
||||||
|
|
||||||
|
@ -75,12 +76,26 @@ func (ml *MessageList) Draw(ctx *ui.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
style := tcell.StyleDefault
|
style := tcell.StyleDefault
|
||||||
|
|
||||||
|
// current row
|
||||||
if row == ml.selected-ml.scroll {
|
if row == ml.selected-ml.scroll {
|
||||||
style = style.Reverse(true)
|
style = style.Reverse(true)
|
||||||
}
|
}
|
||||||
|
// deleted message
|
||||||
if _, ok := store.Deleted[msg.Uid]; ok {
|
if _, ok := store.Deleted[msg.Uid]; ok {
|
||||||
style = style.Foreground(tcell.ColorGray)
|
style = style.Foreground(tcell.ColorGray)
|
||||||
}
|
}
|
||||||
|
// unread message
|
||||||
|
seen := false
|
||||||
|
for _, flag := range msg.Flags {
|
||||||
|
if flag == imap.SeenFlag {
|
||||||
|
seen = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !seen {
|
||||||
|
style = style.Bold(true)
|
||||||
|
}
|
||||||
|
|
||||||
ctx.Fill(0, row, ctx.Width(), 1, ' ', style)
|
ctx.Fill(0, row, ctx.Width(), 1, ' ', style)
|
||||||
fmtStr, args, err := lib.ParseIndexFormat(ml.conf, i, msg)
|
fmtStr, args, err := lib.ParseIndexFormat(ml.conf, i, msg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue