talons

Fork of Claws Mail https://www.claws-mail
Log | Files | Refs | README | LICENSE

commit d7d8bd63dd4026e1da3f19891244ed98c2a7e9e7
parent 68d85558184fd231e529c5fda9db540401b8f528
Author: wwp <subscript@free.fr>
Date:   Fri, 27 Sep 2019 12:09:22 +0200

Syntax highlight improvements, patches by Jakub Kicinski (slightly
adapted to make use of the account_sigsep_matchlist API):
- when '-p' option is used ' @@' can be followed by function name.
- detect git patch in body part.
Added new contributor to authors list.
Fix bug 4130.

Diffstat:
Msrc/gtk/authors.h | 1+
Msrc/textview.c | 15++++++++++++---
Msrc/textview.h | 3++-
3 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/src/gtk/authors.h b/src/gtk/authors.h @@ -328,5 +328,6 @@ static char *CONTRIBS_LIST[] = { "Gál Zoltán", "Marien Zwart", "Martin Zwickel", +"Jakub Kiciński", NULL }; diff --git a/src/textview.c b/src/textview.c @@ -1036,6 +1036,7 @@ static void textview_write_body(TextView *textview, MimeInfo *mimeinfo) textview->is_in_signature = FALSE; textview->is_diff = FALSE; textview->is_attachment = FALSE;; + textview->is_in_git_patch = FALSE; procmime_decode_content(mimeinfo); @@ -1609,7 +1610,7 @@ static void textview_write_line(TextView *textview, const gchar *str, } if (prefs_common.enable_color) { - if (textview->is_diff) { + if (textview->is_diff || textview->is_in_git_patch) { if (strncmp(buf, "+++ ", 4) == 0) fg_color = "diff-add-file"; else if (buf[0] == '+') @@ -1619,13 +1620,21 @@ static void textview_write_line(TextView *textview, const gchar *str, else if (buf[0] == '-') fg_color = "diff-del"; else if (strncmp(buf, "@@ ", 3) == 0 && - strcmp(buf+strlen(buf)-4, " @@\n") == 0) + strstr(&buf[3], " @@")) fg_color = "diff-hunk"; - } else if (account_sigsep_matchlist_str_found(buf,"%s\n") + + if (account_signatures_matchlist_nchar_found(buf, "%s\n") + textview->is_in_git_patch = FALSE; + textview->is_in_signature = TRUE; + fg_color = "signature"; + } + } else if (account_sigsep_matchlist_str_found(buf, "%s\n") || account_sigsep_matchlist_str_found(buf, "- %s\n") || textview->is_in_signature) { fg_color = "signature"; textview->is_in_signature = TRUE; + } else if (strncmp(buf, "diff --git ", 11) == 0) { + textview->is_in_git_patch = TRUE; } } diff --git a/src/textview.h b/src/textview.h @@ -67,7 +67,8 @@ struct _TextView gboolean is_in_signature; gboolean is_diff; gboolean is_attachment; - + gboolean is_in_git_patch; + GSList *uri_list; gint body_pos;