From e37ef122f899daf7b7dee4b391197a3efc9e1f9a Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Tue, 29 Aug 2023 19:11:20 +1000 Subject: [PATCH] rfc822header: improvements to render attribute on headers. 1/ the render:rfc822header-FOO attr is now render:rfc822header:FOO to differentiate from e.g. render:rfc822header-wrap which doesn't identify a header. 2/ The "FOO" in the above is now always lower-case. This removes the need to differentiate between hdr and hdr_found 3/ The value of that attr is the type of header. This will be used more later. 4/ change notmuch to make proper use of some of the above. Signed-off-by: NeilBrown --- lib-rfc822header.c | 14 ++++++++------ python/module-notmuch.py | 14 +++++++------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/lib-rfc822header.c b/lib-rfc822header.c index 132ade78..8030c84a 100644 --- a/lib-rfc822header.c +++ b/lib-rfc822header.c @@ -267,6 +267,7 @@ static void copy_header(struct pane *doc safe, char buf[20]; wint_t ch; char attr[100]; + char *a; int is_list = type && strcmp(type, "list") == 0; m = mark_dup(start); @@ -321,12 +322,13 @@ static void copy_header(struct pane *doc safe, call("doc:replace", p, 1, NULL, "\n", 0, point); snprintf(buf, sizeof(buf), "%zd", strlen(hdr_found)+1); call("doc:set-attr", p, 1, hstart, "render:rfc822header", 0, NULL, buf); - if (strlen(hdr) == strlen(hdr_found)) - /* Refer canonical name, if no 'Resent-' */ - snprintf(attr, sizeof(attr), "render:rfc822header-%s", hdr); - else - snprintf(attr, sizeof(attr), "render:rfc822header-%s", hdr_found); - call("doc:set-attr", p, 1, hstart, attr, 0, NULL, "10000"); + snprintf(attr, sizeof(attr), "render:rfc822header:%s", hdr_found); + /* make header name lowercase */ + for (a = attr; *a; a++) { + if ((unsigned char)(*a) < 128 && isupper(*a)) + *a = tolower(*a); + } + call("doc:set-attr", p, 1, hstart, attr, 0, NULL, type); mark_free(hstart); mark_free(m); diff --git a/python/module-notmuch.py b/python/module-notmuch.py index 5206b1ba..6a11461b 100644 --- a/python/module-notmuch.py +++ b/python/module-notmuch.py @@ -3458,21 +3458,21 @@ class notmuch_message_view(edlib.Pane): def handle_map_attr(self, key, focus, mark, str, str2, comm2, **a): "handle:map-attr" if str == "render:rfc822header": - comm2("attr:callback", focus, int(str2), mark, "fg:#6495ed", 121) + comm2("attr:callback", focus, int(str2), mark, "fg:#6495ed,nobold", 121) comm2("attr:callback", focus, 0, mark, "wrap-tail: ,wrap-head: ", - 119) + 121) return 1 if str == "render:rfc822header-wrap": comm2("attr:callback", focus, int(str2), mark, "wrap", 120) return 1 - if str == "render:rfc822header-subject": - comm2("attr:callback", focus, int(str2), mark, "fg:blue,bold", 120) + if str == "render:rfc822header:subject": + comm2("attr:callback", focus, 10000, mark, "fg:blue,bold", 120) return 1 - if str == "render:rfc822header-to": - comm2("attr:callback", focus, int(str2), mark, "fg:blue,bold", 120) + if str == "render:rfc822header:to": + comm2("attr:callback", focus, 10000, mark, "fg:blue,bold", 120) return 1 if str == "render:hide": - comm2("attr:callback", focus, int(str2), mark, "hide", 100000) + comm2("attr:callback", focus, 10000, mark, "hide", 100000) if str == "render:bold": comm2("attr:callback", focus, 100000 if str2 == "1" else -1, mark, "bold", 120) -- 2.39.5