+ gtk_text_iter_backward_find_char( &end, pred_nonpunct_or_slash, NULL, &start );
+ gtk_text_iter_forward_char(&end);
+
+ gchar* text = gtk_text_iter_get_text( &start, &end );
+ size_t len = strlen(text), prefix_len;
+ size_t n;
+
+ for( n = 0; n < WXSIZEOF(URIPrefixes); ++n )
+ {
+ prefix_len = strlen(URIPrefixes[n]);
+ if((len > prefix_len) && !strncasecmp(text, URIPrefixes[n], prefix_len))
+ break;
+ }
+
+ if(n < WXSIZEOF(URIPrefixes))
+ {
+ gulong signal_id = g_signal_handler_find (buffer,
+ (GSignalMatchType) (G_SIGNAL_MATCH_FUNC),
+ 0, 0, NULL,
+ (gpointer)au_apply_tag_callback, NULL);
+
+ g_signal_handler_block (buffer, signal_id);
+ gtk_text_buffer_apply_tag(buffer, tag, &start, &end);
+ g_signal_handler_unblock (buffer, signal_id);
+ }
+}
+}
+
+extern "C" {
+static void
+au_check_range(GtkTextIter *s,
+ GtkTextIter *range_end)
+{
+ GtkTextIter range_start = *s;
+ GtkTextIter word_end;
+ GtkTextBuffer *buffer = gtk_text_iter_get_buffer(s);
+ GtkTextTag *tag = gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(buffer), "wxUrl");
+
+ gtk_text_buffer_remove_tag(buffer, tag, s, range_end);
+
+ if(g_unichar_isspace(gtk_text_iter_get_char(&range_start)))
+ gtk_text_iter_forward_find_char(&range_start, pred_non_whitespace, NULL, range_end);
+
+ while(!gtk_text_iter_equal(&range_start, range_end))
+ {
+ word_end = range_start;
+ gtk_text_iter_forward_find_char(&word_end, pred_whitespace, NULL, range_end);
+
+ // Now we should have a word delimited by range_start and word_end, correct link tags
+ au_check_word(&range_start, &word_end);
+
+ range_start = word_end;
+ gtk_text_iter_forward_find_char(&range_start, pred_non_whitespace, NULL, range_end);
+ }
+}