soc.2008.finch: 3f5e4317: I think this is what i meant. Need to p...

queueram at soc.pidgin.im queueram at soc.pidgin.im
Tue Jan 27 12:50:26 EST 2009


-----------------------------------------------------------------
Revision: 3f5e4317d279d6238392d0559d9243bfc045ada2
Ancestor: 18944ee44a9f8cd3c8c528e5032171da974431b1
Author: queueram at soc.pidgin.im
Date: 2009-01-27T17:49:21
Branch: im.pidgin.soc.2008.finch
URL: http://d.pidgin.im/viewmtn/revision/info/3f5e4317d279d6238392d0559d9243bfc045ada2

Modified files:
        finch/libgnt/gntentry.c

ChangeLog: 

I think this is what i meant.  Need to pass in the string location relative
to the entry's text instead of the keypress string. Contractions are still
broken due to the current lack of logic to fix previously detected word breaks.

-------------- next part --------------
============================================================
--- finch/libgnt/gntentry.c	6a2b087d107a17a7c45a50852c5e802452a04116
+++ finch/libgnt/gntentry.c	e28482c3b18f4b04612f5902398f195639395209
@@ -460,15 +460,22 @@ is_word_break(const char *start, const c
 	 *    e.g. "This isn't fun."
 	 *                  ^ NOT a word break
 	 *
-	 * To correclty be able to distinguish contractions from end single quotes,
+	 * To correctly be able to distinguish contractions from end single quotes,
 	 * a sliding window of 3 characters must be used:
 	 * "n't" and "e' " from last example of (2) and example from (3)
 	 *
+	 * This is problematic for detection while typing though.  Detection of
+	 * a contraction single quote occurs when the next letter is typed.
+	 * e.g. str(0) = "isn" and no word break was detected
+	 *      str(1) = "isn'" and the "'" is detected to be a word break
+	 *      str(2)  = "isn't" and the "'" is no longer a word break (must be updated)
+	 *
 	 * Two characters cannot be used without some backtracking logic (i.e. realizing a word
 	 * break for the previous character).
 	 */
+#if 1
 	char *pc = NULL, *nc = NULL;
-	gunichar cur_uc, prev_uc = NULL, next_uc = NULL;
+	gunichar cur_uc, prev_uc = 0, next_uc = 0;
 	cur_uc = g_utf8_get_char(wc);
 	if (start)
 	{
@@ -485,7 +492,6 @@ is_word_break(const char *start, const c
 		}
 	}
 
-#if 1
 	return g_unichar_isspace(cur_uc) ||
 		(g_unichar_ispunct(cur_uc) && (pc == NULL || nc == NULL ||
 									   g_unichar_ispunct(prev_uc) || g_unichar_ispunct(next_uc) ||
@@ -1188,7 +1194,7 @@ gnt_entry_key_pressed(GntWidget *widget,
 #ifdef USE_ENCHANT
 			if (entry->spell) {
 				if (entry->spell->cursor_word) {
-					if (is_word_break(entry->start, str, entry->end)) {
+					if (is_word_break(entry->start, entry->cursor, entry->end)) {
 						if (entry->cursor > entry->start + entry->spell->cursor_word->start) {
 							/* The current word just ended. Spell check it */
 							const char *lend = lastw ? (entry->start + lastw->start + lastw->length + 1) : NULL;
@@ -1226,7 +1232,7 @@ gnt_entry_key_pressed(GntWidget *widget,
 								entry->spell->cursor_word->misspelled)
 							check_entry_word(entry, entry->spell->cursor_word);
 					}
-				} else if (!is_word_break(entry->start, str, entry->end)) {
+				} else if (!is_word_break(entry->start, entry->cursor, entry->end)) {
 					/* A new word is starting */
 					GntEntryWord *w = gnt_entry_word_new();
 					w->start = entry->cursor - entry->start;


More information about the Commits mailing list