summary refs log tree commit diff stats
path: root/widgets/headerlayout.go
diff options
context:
space:
mode:
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 c6e6161..7f6b93d 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
 			}