aboutsummaryrefslogtreecommitdiffstats
path: root/filters
diff options
context:
space:
mode:
authorRobin Jarry <robin@jarry.cc>2023-08-24 11:33:21 +0200
committerRobin Jarry <robin@jarry.cc>2023-08-24 14:01:52 +0200
commit606f8f0c701d349c8c1ff061587560cb46c0ba85 (patch)
tree15cd75a2904059d7fcd2941274ef03b852991646 /filters
parenta5d6a70f440f770b41dc345324fa7413b3745e3f (diff)
downloadaerc-606f8f0c701d349c8c1ff061587560cb46c0ba85.tar.gz
colorize: only emit osc8 if [general].enable-osc8=true
Some old versions of less do not handle OSC 8 escape sequences. Even if aerc's embedded terminal is configured to handle them, less corrupts them making the output unreadable. 8;id=colorize-1;https://foobar.com/stuff/https://foobar.com/stuff/ When [general].enable-osc8 is set to false (its default value) do not attempt to generate OSC 8 sequences with the built-in colorize filter. These sequences would be stripped out anyway. Reported-by: Omar Polo <op@omarpolo.com> Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Kirill Chibisov <contact@kchibisov.com>
Diffstat (limited to 'filters')
-rw-r--r--filters/colorize.c22
-rwxr-xr-xfilters/test.sh1
2 files changed, 18 insertions, 5 deletions
diff --git a/filters/colorize.c b/filters/colorize.c
index 6f988158..b00a88c4 100644
--- a/filters/colorize.c
+++ b/filters/colorize.c
@@ -14,10 +14,11 @@
static void usage(void)
{
- puts("usage: colorize [-h] [-s FILE] [-f FILE]");
+ puts("usage: colorize [-h] [-8] [-s FILE] [-f FILE]");
puts("");
puts("options:");
puts(" -h show this help message");
+ puts(" -8 emit OSC 8 hyperlink sequences (default $AERC_OSC8_URLS)");
puts(" -s FILE use styleset file (default $AERC_STYLESET)");
puts(" -f FILE read from filename (default stdin)");
}
@@ -155,6 +156,7 @@ struct styles {
};
static FILE *in_file;
+static bool osc8_urls;
static const char *styleset;
static struct styles styles = {
.url = { .underline = true, .fg = { .type = RGB, .rgb = 0xffffaf } },
@@ -542,9 +544,13 @@ static void urls(const char *in, struct style *ctx)
}
print(seq(&styles.url));
bool email = groups[2].rm_so == -1 && groups[1].rm_so == -1;
- print_osc8(in, len, url_id, email);
+ if (osc8_urls) {
+ print_osc8(in, len, url_id, email);
+ }
in += print_notabs(in, len);
- print_osc8(NULL, 0, url_id, email);
+ if (osc8_urls) {
+ print_osc8(NULL, 0, url_id, email);
+ }
url_id++;
print(RESET);
if (ctx) {
@@ -708,13 +714,17 @@ static void colorize_line(const char *in)
int parse_args(int argc, char **argv)
{
- const char *filename = NULL;
+ const char *filename = NULL, *osc8 = NULL;
int c;
styleset = getenv("AERC_STYLESET");
+ osc8 = getenv("AERC_OSC8_URLS");
- while ((c = getopt(argc, argv, "hs:f:")) != -1) {
+ while ((c = getopt(argc, argv, "h8s:f:")) != -1) {
switch (c) {
+ case '8':
+ osc8 = "1";
+ break;
case 's':
styleset = optarg;
break;
@@ -741,6 +751,8 @@ int parse_args(int argc, char **argv)
return 1;
}
}
+ osc8_urls = osc8 != NULL;
+
return 0;
}
diff --git a/filters/test.sh b/filters/test.sh
index 65a1d4d3..78a52fff 100755
--- a/filters/test.sh
+++ b/filters/test.sh
@@ -4,6 +4,7 @@ set -e
here=$(dirname $0)
fail=0
+export AERC_OSC8_URLS=1
for vec in $here/vectors/*.in; do
tool=$(basename $vec | sed 's/-.*//')