-
- 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);
- }
-}
-
-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);
- }
-}
-
-//-----------------------------------------------------------------------------
-// "insert-text" for GtkTextBuffer
-//-----------------------------------------------------------------------------
-
-static void
-au_insert_text_callback(GtkTextBuffer *buffer,
- GtkTextIter *end,
- gchar *text,
- gint len,
- wxTextCtrl *win)
-{
- if (!len || !(win->GetWindowStyleFlag() & wxTE_AUTO_URL) )
- return;
-
- GtkTextIter start = *end;
- gtk_text_iter_backward_chars(&start, g_utf8_strlen(text, len));
-
- GtkTextIter line_start = start;
- GtkTextIter line_end = *end;
- GtkTextIter words_start = start;
- GtkTextIter words_end = *end;
-
- gtk_text_iter_set_line(&line_start, gtk_text_iter_get_line(&start));
- gtk_text_iter_forward_to_line_end(&line_end);
- gtk_text_iter_backward_find_char(&words_start, pred_whitespace, NULL, &line_start);
- gtk_text_iter_forward_find_char(&words_end, pred_whitespace, NULL, &line_end);
-
- au_check_range(&words_start, &words_end);