diff options
author | Robin Jarry <robin@jarry.cc> | 2023-01-15 23:27:29 +0100 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2023-01-26 00:20:48 +0100 |
commit | 98e32d2ff22cba1e60caf6a252eee0d38f26f736 (patch) | |
tree | 249564b1942d0a42225243a8a598ec48bc896c6b /stylesets | |
parent | 3191ee171c435a43912264b131340af66fea8112 (diff) | |
download | aerc-98e32d2ff22cba1e60caf6a252eee0d38f26f736.tar.gz |
filters: rewrite colorize in c
Since its introduction, we had multiple issues with the colorize awk
script with regard to non-GNU awk compatibility.
Also, this script is standalone and the color theme must be hard coded
into it. Reading from an external configuration file (aerc's styleset)
from a non-GNU awk is close to impossible (and even far from trivial
with GNU awk).
Rewrite the builtin colorize filter in C to allow getting the color
theme from aerc's active styleset. The theme is configured using the
existing styleset syntax and attributes under a separate [viewer]
section (see examples and man page).
Export the active styleset file path to AERC_STYLESET env var when
invoking the filter command so that colorize can access it and use it.
I have tested compilation (with clang-analyzer and gcc -fanalyzer) and
basic operation on FreeBSD, Fedora (glibc) and Alpine (muslibc). More
tests would probably be required on MacOSX and older Linux distros.
I also added test vectors to give some confidence that this works as
expected. The execution with these vectors passed valgrind
--leak-check=full without errors.
NB: the default theme has changed to be more minimal. Sample stylesets
have more colorful examples. The awk -v theme=xxx option is no longer
supported.
usage: colorize [-h] [-s FILE] [-f FILE]
options:
-h show this help message
-s FILE use styleset file (default $AERC_STYLESET)
-f FILE read from filename (default stdin)
Signed-off-by: Robin Jarry <robin@jarry.cc>
Tested-by: Bence Ferdinandy <bence@ferdinandy.com>
Acked-by: Moritz Poldrack <moritz@poldrack.dev>
Diffstat (limited to 'stylesets')
-rw-r--r-- | stylesets/blue | 16 | ||||
-rw-r--r-- | stylesets/default | 12 | ||||
-rw-r--r-- | stylesets/dracula | 12 | ||||
-rw-r--r-- | stylesets/nord | 12 | ||||
-rw-r--r-- | stylesets/pink | 16 |
5 files changed, 68 insertions, 0 deletions
diff --git a/stylesets/blue b/stylesets/blue index 29e165be..7ae019d2 100644 --- a/stylesets/blue +++ b/stylesets/blue @@ -45,3 +45,19 @@ default.selected.fg=white default.selected.bg=#005f87 completion_default.selected.bg=#005f87 + +[viewer] +url.fg=#ffffaf +url.underline=true +header.fg=#af87ff +signature.fg=#af87ff +diff_meta.fg=#ffffff +diff_meta.bold=true +diff_chunk.fg=#00cdcd +diff_add.fg=#00cd00 +diff_del.fg=#cd0000 +quote_1.fg=#5fafff +quote_2.fg=#ff8700 +quote_3.fg=#af87ff +quote_4.fg=#ff5fd7 +quote_x.fg=#808080 diff --git a/stylesets/default b/stylesets/default index 078920bf..5ee1c4e0 100644 --- a/stylesets/default +++ b/stylesets/default @@ -35,3 +35,15 @@ border.reverse = true selector_focused.reverse=true selector_chooser.bold=true + +[viewer] +url.underline=true +header.bold=true +signature.dim=true +diff_meta.bold=true +diff_chunk.dim=true +diff_add.fg=2 +diff_del.fg=1 +quote_*.fg=6 +quote_*.dim=true +quote_1.dim=false diff --git a/stylesets/dracula b/stylesets/dracula index 10f21a5e..c400865a 100644 --- a/stylesets/dracula +++ b/stylesets/dracula @@ -46,3 +46,15 @@ default.selected.bg=#44475A completion_default.selected.bg=#44475A completion_default.selected.fg=white + +[viewer] +url.underline=true +header.bold=true +signature.dim=true +diff_meta.bold=true +diff_chunk.dim=true +diff_add.fg=2 +diff_del.fg=1 +quote_*.fg=6 +quote_*.dim=true +quote_1.dim=false diff --git a/stylesets/nord b/stylesets/nord index 5f5274f7..8f7d5140 100644 --- a/stylesets/nord +++ b/stylesets/nord @@ -44,3 +44,15 @@ tab.selected.fg=#2c3441 dirlist_unread.fg=#64A6B3 dirlist_recent.fg=#64A6B3 + +[viewer] +url.underline=true +header.bold=true +signature.dim=true +diff_meta.bold=true +diff_chunk.dim=true +diff_add.fg=2 +diff_del.fg=1 +quote_*.fg=6 +quote_*.dim=true +quote_1.dim=false diff --git a/stylesets/pink b/stylesets/pink index 743da359..792771a2 100644 --- a/stylesets/pink +++ b/stylesets/pink @@ -47,3 +47,19 @@ default.selected.fg=white default.selected.bg=#de4e85 completion_default.selected.bg=#de4e85 + +[viewer] +url.fg=#ffffaf +url.underline=true +header.fg=#af87ff +signature.fg=#af87ff +diff_meta.fg=#ffffff +diff_meta.bold=true +diff_chunk.fg=#00cdcd +diff_add.fg=#00cd00 +diff_del.fg=#cd0000 +quote_1.fg=#5fafff +quote_2.fg=#ff8700 +quote_3.fg=#af87ff +quote_4.fg=#ff5fd7 +quote_x.fg=#808080 |