summary refs log tree commit diff stats
path: root/templates
diff options
context:
space:
mode:
authorNĂ­colas F. R. A. Prado <nfraprado@protonmail.com>2021-03-06 18:03:36 +0000
committerReto Brunner <reto@labrat.space>2021-03-07 14:53:37 +0100
commit3df88f70408a2946862187056a80cfccc655e5cc (patch)
tree1bfbddee33ceaae077fb01a4ee9bcdee4f11d08b /templates
parent413fc431f76585b09845d6b2555f7d85d5667ee3 (diff)
downloadaerc-3df88f70408a2946862187056a80cfccc655e5cc.tar.gz
templates: Use wrap instead of wrapText
bf0f72a533d5 ("template: add exec and wrap") introduced wrap which
allowed to chain wrapText. It also changed the aerc-templates man page
to document wrap instead of wrapText. The templates weren't updated
then, so update now.
Diffstat (limited to 'templates')
-rw-r--r--templates/forward_as_body2
-rw-r--r--templates/quoted_reply2
2 files changed, 2 insertions, 2 deletions
diff --git a/templates/forward_as_body b/templates/forward_as_body
index 7459971..455d2ba 100644
--- a/templates/forward_as_body
+++ b/templates/forward_as_body
@@ -1,3 +1,3 @@
 
 Forwarded message from {{(index .OriginalFrom 0).Name}} on {{dateFormat .OriginalDate "Mon Jan 2, 2006 at 3:04 PM"}}:
-{{wrapText .OriginalText 72}}
+{{wrap .OriginalText 72}}
diff --git a/templates/quoted_reply b/templates/quoted_reply
index 1077e1c..eeacb6d 100644
--- a/templates/quoted_reply
+++ b/templates/quoted_reply
@@ -1,3 +1,3 @@
 
 On {{dateFormat (.OriginalDate | toLocal) "Mon Jan 2, 2006 at 3:04 PM MST"}}, {{(index .OriginalFrom 0).Name}} wrote:
-{{wrapText .OriginalText 72 | quote }}
+{{wrap .OriginalText 72 | quote }}
/* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
package widgets

import (
	"git.sr.ht/~sircmpwn/aerc/lib/ui"
	"git.sr.ht/~sircmpwn/aerc/models"
)

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 (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 filter.keep(msg, col) {
				result = append(result, row)
				break
			}
		}
	}
	return result
}

// grid builds a ui grid, populating each cell by calling a callback function
// with the current header string.
func (layout HeaderLayout) grid(cb func(string) ui.Drawable) (grid *ui.Grid, height int) {
	rowCount := len(layout)
	grid = ui.MakeGrid(rowCount, 1, ui.SIZE_EXACT, ui.SIZE_WEIGHT)
	for i, cols := range layout {
		r := ui.MakeGrid(1, len(cols), ui.SIZE_EXACT, ui.SIZE_WEIGHT)
		for j, col := range cols {
			r.AddChild(cb(col)).At(0, j)
		}
		grid.AddChild(r).At(i, 0)
	}
	return grid, rowCount
}