`regexp` feature uses the pcre2 library to enable the user to define
regular expressions for matching text and applying text formatting to
the matches. An example from the theme configuration I used to test
this:
[terminal.themes.win95.text_format_regexps]
"listing.subject" = { "\\[[^\\]]*\\]" = { attrs = "Bold" } }
"listing.from" = { "\\<[^\\>]*\\>(?:(?:\\s*$)|(?=,))" = { attrs = "Italics" } }
[terminal.themes.win95.text_format_regexps."pager.envelope.body"]
"^>.*$" = { attrs = "Italics" }
"\\d+\\s?(?:(?:[KkMmTtGg]?[Bb])|(?:[KkMmTtGg][Bb]?)(?=\\s))" = { attrs = "Bold | Underline" }
FormatTag describes a set of attributes, colors that exist in a
tag_table field of CellBuffer. The field of tag_associations contains
the hash of a tag and the {start,end} index of the cells that have this
attribute. A tag can thus be used many times.
An example of use is
let t = self.pager.insert_tag(FormatTag {
attrs: Attr::ITALICS,
..Default::default()
});
debug!("FormatTag hash = {}", t);
let (width, height) = self.pager.size();
for i in 0..height {
if self.pager.content[(0, i)].ch() == '>' {
self.pager.set_tag(t, (0, i), (width.saturating_sub(1), i));
}
}
This will set reply lines in text as italics.
This feature interface is not used anywhere yet.
Add aliases to avoid repetition of raw values when defining new themes.
Aliases are strings starting with "$" and must be defined in the
`color_aliases` and `attr_aliases` fields of a theme.
Theme attribute values can refer to another theme key instead of
defining a value. Add support for optionally defining the theme key's
field by appending a ".fg" or ".bg" suffix to the link's key.
Add grammar for execute commands and parser to identify possible next
tokens for the user's execute command input.
The grammar is given as a sequence of Tokens in each command's
definition. The parser parses the user's input according to this
grammar, and returns the tokens that could come next, if any.
Add attribute escape sequence support in terminal::ansi, which handles
converting strings with ansi escape sequences into meli's internal
terminal structures in order to incorporate them into the UI.
Execute user provided command invocations $CMD such as `editor_cmd` with
`/bin/sh` as `/bin/sh -c "$CMD"
Previously, user commands were split by whitespace which must trigger
erroneous behavior if quotes are involved.
If user config file overwrites a single attribute and not the others,
for example only bg:
"mail.listing.tag_default" = { bg = "Blue" }
The other attributes, in this case fg and attrs revert to the default
values of ThemeAttributeInner and not the default value for the key
"mail.listing.tag_default". As a result the above expands to:
"mail.listing.tag_default" = { fg = Color::Default, bg = "Blue", attrs
= Attr::Default }
This commit keeps the key value defaults, so the above should expand to:
"mail.listing.tag_default" = { fg = default_theme["mail.listing.tag_default"].fg, bg = "Blue", attrs
= default_theme["mail.listing.tag_default"].attrs }
Attribute links are not checked for validity in theme validation, and an
invalid link would cause a panic in is_cyclic.
This commit improves the theme validation errors by printing if the
error lies in a theme key or a link.
Text attributes have been rewritten as bit flags, so for example instead of
"BoldUnderline" you'd have to define "Bold | Underline" in your theme
settings.
Requested in #21
conf_override! wraps struct definitions and defines a secondary Override
struct that wraps each field in an Option. The macro mailbox_settings!
is used to select settings from an account & mailbox index. If a user defines an overriding setting, the macro returns the override instead of the immediately next in the hierarchy setting.
The selection is done for a specific field as follows:
if per-folder override is defined, return per-folder override
else if per-account override is defined, return per-account override
else return global setting field value.