[geany/geany-plugins] 8af8d5: geanylatex: Allow for multiple spaces after punctuation when capitalizing

Colomban Wendling git-noreply at xxxxx
Sat Apr 12 17:59:35 UTC 2014


Branch:      refs/heads/master
Author:      Colomban Wendling <ban at herbesfolles.org>
Committer:   Colomban Wendling <ban at herbesfolles.org>
Date:        Sat, 12 Apr 2014 17:59:35 UTC
Commit:      8af8d52b74f8530eb3b8bf478c8ca558f5bf2507
             https://github.com/geany/geany-plugins/commit/8af8d52b74f8530eb3b8bf478c8ca558f5bf2507

Log Message:
-----------
geanylatex: Allow for multiple spaces after punctuation when capitalizing

Allow form multiple white spaces (including newlines) after a
punctuation when checking whether to capitalize the sentence start.

This is useful because some people are used to write two spaces between
sentences, and it also allows to capitalize the first sentence of a new
paragraph.


Modified Paths:
--------------
    geanylatex/src/geanylatex.c

Modified: geanylatex/src/geanylatex.c
24 files changed, 18 insertions(+), 6 deletions(-)
===================================================================
@@ -700,12 +700,24 @@ static gboolean on_editor_notify(G_GNUC_UNUSED GObject *object, GeanyEditor *edi
 				}
 				default:
 				{
-					if (glatex_capitalize_sentence_starts == TRUE)
+					if (glatex_capitalize_sentence_starts == TRUE &&
+						g_ascii_isspace(get_char_relative(sci, pos, -2)))
 					{
-						if (get_char_relative(sci, pos, -2) == ' ' &&
-							(get_char_relative(sci, pos, -3) == '.' ||
-							 get_char_relative(sci, pos, -3) == '!' ||
-							 get_char_relative(sci, pos, -3) == '?'))
+						gint prevNonWhite = 0;
+						gint i;
+
+						/* find the previous non-white character */
+						i = get_position_relative(sci, pos, -3);
+						while (g_ascii_isspace((prevNonWhite = sci_get_char_at(sci, i))))
+						{
+							/* no need to bother about multi-byte characters here since
+							 * we only check for ASCII space characters anyway */
+							--i;
+						}
+
+						if (prevNonWhite == '.' ||
+							prevNonWhite == '!' ||
+							prevNonWhite == '?')
 						{
 							gchar *upperLtr = NULL;
 							gchar *selection = NULL;
@@ -720,8 +732,8 @@ static gboolean on_editor_notify(G_GNUC_UNUSED GObject *object, GeanyEditor *edi
 							g_free(upperLtr);
 							g_free(selection);
 						}
-						break;
 					}
+					break;
 				}
 			} /* Closing switch  */
 			/* later there could be some else ifs for other keywords */



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Plugins-Commits mailing list