aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/headerlayout.go
diff options
context:
space:
mode:
authorReto Brunner <reto@labrat.space>2019-12-23 12:51:59 +0100
committerDrew DeVault <sir@cmpwn.com>2019-12-27 10:20:30 -0700
commitb360cca977bdf29d19764712d97af22e9165e2d0 (patch)
treedab310e9dd85d6eeba2856703527f5a99cfeee15 /widgets/headerlayout.go
parent63391b7dca09e3f2cf3c4ff903592d23fe8f56a3 (diff)
downloadaerc-b360cca977bdf29d19764712d97af22e9165e2d0.tar.gz
msgviewer: Add Labels as a virtual header
In order to accommodate for that, the headerlayout needed to be rewritten to pass the filter criteria back to the msgviewer, instead of just using the normal headers.
Diffstat (limited to 'widgets/headerlayout.go')
-rw-r--r--widgets/headerlayout.go14
1 files changed, 9 insertions, 5 deletions
diff --git a/widgets/headerlayout.go b/widgets/headerlayout.go
index c6e61615..7f6b93d3 100644
--- a/widgets/headerlayout.go
+++ b/widgets/headerlayout.go
@@ -7,15 +7,19 @@ import (
type HeaderLayout [][]string
+type HeaderLayoutFilter struct {
+ layout HeaderLayout
+ keep func(msg *models.MessageInfo, header string) bool // filter criteria
+}
+
// forMessage returns a filtered header layout, removing rows whose headers
// do not appear in the provided message.
-func (layout HeaderLayout) forMessage(msg *models.MessageInfo) HeaderLayout {
- headers := msg.RFC822Headers
- result := make(HeaderLayout, 0, len(layout))
- for _, row := range layout {
+func (filter HeaderLayoutFilter) forMessage(msg *models.MessageInfo) HeaderLayout {
+ result := make(HeaderLayout, 0, len(filter.layout))
+ for _, row := range filter.layout {
// To preserve layout alignment, only hide rows if all columns are empty
for _, col := range row {
- if headers.Get(col) != "" {
+ if filter.keep(msg, col) {
result = append(result, row)
break
}