aboutsummaryrefslogtreecommitdiffstats
path: root/models/templates.go
Commit message (Collapse)AuthorAgeFilesLines
* templates: add a template for forwaded messagesinwit2024-08-201-0/+1
| | | | | | | | | | | Add a {{.IsForwarded}} template to tell if a message has been forwarded or not. Changelog-added: Forwarded messages can be identified with the {{.IsForwarded}} template. Signed-off-by: inwit <inwit@sindominio.net> Acked-by: Robin Jarry <robin@jarry.cc>
* templates: add {{.AccountFrom}} templateBence Ferdinandy2024-08-031-0/+1
| | | | | | | | | | Add template variable to access the current account's From address. Implements: https://todo.sr.ht/~rjarry/aerc/150 Changelog-added: New `{{.AccountFrom}}` template variable. Signed-off-by: Bence Ferdinandy <bence@ferdinandy.com> Tested-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* threadbuilder: show siblings even when no parent foundKoni Marti2024-06-251-0/+1
| | | | | | | | | | | | | | | Show all threading associations even when not all nodes are present. Indicate if a thread is incomplete, i.e. misses a direct parent node. Use the `msglist_thread_orphan.fg=red` styleobject in your stylesheet to indicate whether a messsage has a missing parent. Also use a different thread prefix ("┬─" instead of "├─") not to confuse them with regular threads that have a visible parent. Signed-off-by: Koni Marti <koni.marti@gmail.com> Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Matěj Cepl <mcepl@cepl.eu>
* templates: add .AccountBackendBence Ferdinandy2024-06-051-0/+1
| | | | | | | | | | | It's useful to know what the current account's backend is, especially if one has multiple configs where the same account name might use a different backend. Add AccountBackend to templates. Changelog-added: Added `{{.AccountBackend}}` to templates. Signed-off-by: Bence Ferdinandy <bence@ferdinandy.com> Acked-by: Robin Jarry <robin@jarry.cc>
* flags: add support for draft flagJason Cox2024-01-261-0/+1
| | | | | | | | | | | | | | Support the draft flag wherever flags are used. Automatically set it when postponing a message, and allow recalling a message without the -f flag if it has the draft flag set, regardless of what folder it's in. Notmuch doesn't seem to pick up on the draft flag when indexing even though the flag is set on the maildir file. Explicitly set all tags corresponding to set flags when appending a message in notmuch. Changelog-added: Support the `draft` flag. Signed-off-by: Jason Cox <me@jasoncarloscox.com> Acked-by: Robin Jarry <robin@jarry.cc>
* templates: move signature from compose to templatesBence Ferdinandy2024-01-081-0/+1
| | | | | | | | | | | | | | | | Currently, when composing a new message, everything is read from the template files, except the signature, which is added directly in the compose code. Add a new template variable {{.Signature}}, by moving the logic of reading signature from command or file from compose to templates. Update the various default template files to preserve the original placement of signatures. Users using the default templates should not notice the change. Users with custom compose templates will need to update their templates with {{.Signature}}. Changelog-changed: Signature placement is now controlled via the `{{.Signature}}` template variable and not hardcoded. Signed-off-by: Bence Ferdinandy <bence@ferdinandy.com> Acked-by: Robin Jarry <robin@jarry.cc>
* templates: add full path of file(s) as Filename(s)Bence Ferdinandy2023-12-311-0/+2
| | | | | | | | | | | | | For the maildir and notmuch backends, add the full path of the message as Filename to templates. In case of a notmuch message having multiple files associated with it, it returns a random path. Also add Filenames to templates, which is a list of all associated message paths. This is relevant for the notmuch backend, where a single messages is shown, if there are multiple copies of it. Changelog-added: Add filepath to messages in templates as .Filename(s) Signed-off-by: Bence Ferdinandy <bence@ferdinandy.com> Acked-by: Robin Jarry <robin@jarry.cc>
* threads: add .ThreadUnread to template datainwit2023-11-121-0/+1
| | | | | | | | | | | | | | | | | When a thread is folded, it can be useful to know how many unseen messages lie below the root. For example, one might want to show that count in the message list: column-folded = {{if .ThreadFolded \ }}{{if ne .ThreadUnread 0 \ }}{{.ThreadUnread | printf "%s/"}}{{ \ end}}{{ .ThreadCount | printf "%s"}}{{end}} Add `.ThreadUnread` to the template functions. Changelog-added: `.ThreadUnread` is now available in templates. Signed-off-by: inwit <inwit@sindominio.net> Acked-by: Robin Jarry <robin@jarry.cc>
* ui: enable showing of thread-contextTim Culverhouse2023-09-271-0/+1
| | | | | | | | | | | | | | | Add a UI config value to enable showing of "thread-context", similar to `notmuch show --entire-thread=true`. Add an associated style called "msglist_thread_context" which can be used to style such messages. Currently this feature is only supported by notmuch. It would be possible for maildir to implement as well, IMAP with gmail custom extensions, and JMAP. This patch merely implements the notmuch version and puts the groundwork in for handling these sorts of displays. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Tested-by: Inwit <inwit@sindominio.net> Acked-by: Robin Jarry <robin@jarry.cc>
* templates: attach directly from templatesKoni Marti2023-08-031-0/+1
| | | | | | | | | | | | | | | | | | Attach a file from templates. Add a split template function. {{- .Attach "LICENSE" -}} or {{range (exec "find ./doc -type f -name *.scd" "" | split "\n") -}} {{with . }} {{- $.Attach . -}} {{- end}} {{- end}} Fixes: https://todo.sr.ht/~rjarry/aerc/109 Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* templates: add ThreadCount and ThreadFoldedKoni Marti2023-07-161-0/+2
| | | | | | | | | | | | | | Add the number of threads and a flag to indicated folded threads to the template data. Use {{.ThreadCount}} and {{.ThreadFolded}} in template expression for the message list. column-subject = {{.ThreadPrefix}}{{if .ThreadFolded}}[{{.ThreadCount}}] {{end}}{{.Subject}} Update default configuration accordingly. Signed-off-by: Koni Marti <koni.marti@gmail.com> Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: inwit <inwit@sindominio.net>
* templates: add map functionsRobin Jarry2023-06-101-0/+2
| | | | | | | | | Similar to switch and .StyleSwitch, add map and .StyleMap to work on lists. An extra "exclude" item is available to filter elements out of the list. Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Inwit <inwit@sindominio.net>
* templates: add boolean flagsRobin Jarry2023-05-201-0/+6
| | | | | | | | | | | | | | | | | | Allow accessing email flags via boolean properties instead of having to rely on obscure regular expressions on (.Flags | join ""). With this patch, it is now possible to do this: [ui] index-columns = star:1,name<15%,reply:1,subject,size>=,date>= column-star = {{if .IsFlagged}}★{{end}} column-name = {{if eq .Role "sent"}}{{.To | names | join ", "}}{{else}}{{.From | names | join ", "}}{{end}} column-reply = {{if .IsReplied}}{{end}} column-subject = {{.ThreadPrefix}}{{.Subject}} column-size = {{if .HasAttachment}}📎 {{end}}{{humanReadable .Size}} column-date = {{.DateAutoFormat .Date.Local}} Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Koni Marti <koni.marti@gmail.com>
* templates: use template interface consistentlyKoni Marti2023-05-161-0/+1
| | | | | | | | | | | | | | | Use the template interface consistently. Before, we have exported the state.TemplateData struct and used it in most places instead of the models.TemplateData interface. This lead to some inconsistencies, i.e. Role() has been defined on the exported struct but not on the interface. Unexport the state.TemplateData struct, add a DataSetter interface to set the data needed for the template data and call the Data() method which returns a models.TemplateData interface when the template data is needed. Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
* templates: add conditional style methodRobin Jarry2023-03-081-0/+1
| | | | | | | | | | | | | Add .StyleSwitch that takes a string and an arbitrary number of cases (regexp, style). Reuse some of the constructs introduced by previous commit. The style of the first regular expression that matches will be applied. If the string does not match any of the expressions, it will be left as-is. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
* templates: add switch/case functionsRobin Jarry2023-03-081-0/+5
| | | | | | | This allows much shorter templates. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
* templates: make SubjectBase official apiRobin Jarry2023-03-081-0/+1
| | | | | | | | Document .SubjectBase. Fix its value along the way. Do not reuse d.Subject() which may be empty if d.threadSameSubject is true. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
* templates: separate thread prefix from subjectRobin Jarry2023-03-081-0/+1
| | | | | | | | Extract {{.ThreadPrefix}} from {{.Subject}} so that the prefix can be styled in a different color. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
* templates: allow inline user stylesTim Culverhouse2023-03-021-0/+1
| | | | | | | | | | | | | | | | | | | | Allow custom user-defined styles in a styleset. The styles can take any name, and must be under the [user] ini section. All attributes apply to user defined styles. Example: [user] red.fg=red red.bold=true Add a .Style function which accepts the name of a user-defined style and applies it to the string. {{.Style "red" "foo"}} Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* dirlist: use templates instead of % mini languageRobin Jarry2023-02-201-0/+1
| | | | | | | | | | | Replace dirlist-format with two settings: dirlist-left & dirlist-right. These two settings take aerc-templates(7) and may be left empty. Add automatic translation of dirlist-format to these new settings. Display a warning on startup if dirlist-format has been converted. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
* statusline: add column based render formatRobin Jarry2023-02-201-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In the spirit of commit 535300cfdbfc ("config: add columns based index format"), reuse the column definitions and table widget. Add automatic translation of render-format to column definitions. Allow empty columns to be compatible with the %m (mute) flag. Rename the State object to AccountState to be more precise. Reuse that object in state.TempateData to expose account state info. Move actual status line rendering in StatusLine.Draw(). Add new template fields for status specific data: {{.ConnectionInfo}} Connection state. {{.ContentInfo}} General status information (e.g. filter, search) {{.StatusInfo}} Combination of {{.ConnectionInfo}} and {{.StatusInfo}} {{.TrayInfo}} General on/off information (e.g. passthrough, threading, sorting) {{.PendingKeys}} Currently pressed key sequence that does not match any key binding and/or is incomplete. Display a warning on startup if render-format has been converted to status-columns. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
* templates: add message counts for specific foldersRobin Jarry2023-02-201-3/+3
| | | | | | | | | Change the {{.Recent}}, {{.Unread}} and {{.Exists}} template fields to take an arbitrary number of folder names as arguments. If no folder name is specified, these return the counts for all folders. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
* templates: unify data interfaceRobin Jarry2023-02-201-0/+36
Require that all aerc template data objects implement the same TemplateData interface. Implement that interface in two different places: 1) state.TemplateData (renamed/moved from templates.TemplateData). This structure (along with all its methods) needs to be decoupled from the templates package to break the import cycle with the config package. This allows much simpler construction of this object and ensure that values are calculated only when requested. 2) config.dummyData (extracted from templates). This is only used in the config package to validate user templates. Putting it here allows also to break an import cycle. Use state.TemplateData everywhere (including for account tabs title rendering). Signed-off-by: Robin Jarry <robin@jarry.cc> Reviewed-by: Moritz Poldrack <moritz@poldrack.dev>