diff options
Diffstat (limited to 'pluma/pluma-document.c')
-rw-r--r-- | pluma/pluma-document.c | 109 |
1 files changed, 72 insertions, 37 deletions
diff --git a/pluma/pluma-document.c b/pluma/pluma-document.c index ed8ca1fa..8634636f 100644 --- a/pluma/pluma-document.c +++ b/pluma/pluma-document.c @@ -1922,13 +1922,24 @@ pluma_document_search_forward (PlumaDocument *doc, while (!found) { + if(!PLUMA_SEARCH_IS_MATCH_REGEX(doc->priv->search_flags)) + { found = gtk_text_iter_forward_search (&iter, - doc->priv->search_text, - search_flags, - &m_start, - &m_end, - end); - + doc->priv->search_text, + search_flags, + &m_start, + &m_end, + end); + }else{ + found = pluma_gtk_text_iter_regex_search (&iter, + doc->priv->search_text, + search_flags, + &m_start, + &m_end, + end, + TRUE); + } + if (found && PLUMA_SEARCH_IS_ENTIRE_WORD (doc->priv->search_flags)) { found = gtk_text_iter_starts_word (&m_start) && @@ -1960,23 +1971,23 @@ pluma_document_search_forward (PlumaDocument *doc, **/ gboolean pluma_document_search_backward (PlumaDocument *doc, - const GtkTextIter *start, - const GtkTextIter *end, - GtkTextIter *match_start, - GtkTextIter *match_end) + const GtkTextIter *start, + const GtkTextIter *end, + GtkTextIter *match_start, + GtkTextIter *match_end) { GtkTextIter iter; GtkTextSearchFlags search_flags; gboolean found = FALSE; GtkTextIter m_start; GtkTextIter m_end; - + g_return_val_if_fail (PLUMA_IS_DOCUMENT (doc), FALSE); - g_return_val_if_fail ((start == NULL) || - (gtk_text_iter_get_buffer (start) == GTK_TEXT_BUFFER (doc)), FALSE); - g_return_val_if_fail ((end == NULL) || + g_return_val_if_fail ((start == NULL) || +( gtk_text_iter_get_buffer (start) == GTK_TEXT_BUFFER (doc)), FALSE); + g_return_val_if_fail ((end == NULL) || (gtk_text_iter_get_buffer (end) == GTK_TEXT_BUFFER (doc)), FALSE); - + if (doc->priv->search_text == NULL) { pluma_debug_message (DEBUG_DOCUMENT, "doc->priv->search_text == NULL\n"); @@ -1984,7 +1995,7 @@ pluma_document_search_backward (PlumaDocument *doc, } else pluma_debug_message (DEBUG_DOCUMENT, "doc->priv->search_text == \"%s\"\n", doc->priv->search_text); - + if (end == NULL) gtk_text_buffer_get_end_iter (GTK_TEXT_BUFFER (doc), &iter); else @@ -1999,32 +2010,45 @@ pluma_document_search_backward (PlumaDocument *doc, while (!found) { - found = gtk_text_iter_backward_search (&iter, - doc->priv->search_text, - search_flags, - &m_start, - &m_end, - start); - + if(!PLUMA_SEARCH_IS_MATCH_REGEX(doc->priv->search_flags)) + { + found = gtk_text_iter_backward_search (&iter, + doc->priv->search_text, + search_flags, + &m_start, + &m_end, + start); + } + else + { + found = pluma_gtk_text_iter_regex_search (&iter, + doc->priv->search_text, + search_flags, + &m_start, + &m_end, + end, + FALSE); + } + if (found && PLUMA_SEARCH_IS_ENTIRE_WORD (doc->priv->search_flags)) { - found = gtk_text_iter_starts_word (&m_start) && - gtk_text_iter_ends_word (&m_end); + found = gtk_text_iter_starts_word (&m_start) && + gtk_text_iter_ends_word (&m_end); - if (!found) + if (!found) iter = m_start; } else break; } - + if (found && (match_start != NULL)) *match_start = m_start; - + if (found && (match_end != NULL)) *match_end = m_end; - - return found; + + return found; } /* FIXME this is an issue for introspection regardning @find */ @@ -2089,12 +2113,23 @@ pluma_document_replace_all (PlumaDocument *doc, do { - found = gtk_text_iter_forward_search (&iter, - search_text, - search_flags, - &m_start, - &m_end, - NULL); + if(!PLUMA_SEARCH_IS_MATCH_REGEX(flags)) + { + found = gtk_text_iter_forward_search (&iter, + search_text, + search_flags, + &m_start, + &m_end, + NULL); + }else{ + found = pluma_gtk_text_iter_regex_search (&iter, + search_text, + search_flags, + &m_start, + &m_end, + NULL, + TRUE); + } if (found && PLUMA_SEARCH_IS_ENTIRE_WORD (flags)) { @@ -2123,7 +2158,7 @@ pluma_document_replace_all (PlumaDocument *doc, replace_text_len); iter = m_start; - } + } } while (found); |