summaryrefslogtreecommitdiff
path: root/pluma
diff options
context:
space:
mode:
authorV.Barkov <[email protected]>2016-11-20 19:28:02 +0300
committerV.Barkov <[email protected]>2016-11-20 19:28:02 +0300
commit29f4e11f08ef02d6a3c6623b8a445502e3e98ed6 (patch)
tree3fbfcf64f603e98d99d4fec53ff4aaaa17ab7c20 /pluma
parent975393b8de593f6f6cab3cc12cfce0f34c475706 (diff)
downloadpluma-29f4e11f08ef02d6a3c6623b8a445502e3e98ed6.tar.bz2
pluma-29f4e11f08ef02d6a3c6623b8a445502e3e98ed6.tar.xz
Implemented "replace all" behavior for regexp
Diffstat (limited to 'pluma')
-rw-r--r--pluma/pluma-commands-search.c3
-rw-r--r--pluma/pluma-document.c37
2 files changed, 27 insertions, 13 deletions
diff --git a/pluma/pluma-commands-search.c b/pluma/pluma-commands-search.c
index 6903d381..393b088a 100644
--- a/pluma/pluma-commands-search.c
+++ b/pluma/pluma-commands-search.c
@@ -431,6 +431,7 @@ do_replace_all (PlumaSearchDialog *dialog,
const gchar *search_entry_text;
const gchar *replace_entry_text;
gboolean match_case;
+ gboolean match_regex;
gboolean entire_word;
gboolean parse_escapes;
guint flags = 0;
@@ -460,9 +461,11 @@ do_replace_all (PlumaSearchDialog *dialog,
g_return_if_fail ((replace_entry_text) != NULL);
match_case = pluma_search_dialog_get_match_case (dialog);
+ match_regex = pluma_search_dialog_get_match_regex(dialog);
entire_word = pluma_search_dialog_get_entire_word (dialog);
PLUMA_SEARCH_SET_CASE_SENSITIVE (flags, match_case);
+ PLUMA_SEARCH_SET_MATCH_REGEX (flags, match_regex);
PLUMA_SEARCH_SET_ENTIRE_WORD (flags, entire_word);
count = pluma_document_replace_all (doc,
diff --git a/pluma/pluma-document.c b/pluma/pluma-document.c
index 43abf989..11ad1372 100644
--- a/pluma/pluma-document.c
+++ b/pluma/pluma-document.c
@@ -2009,12 +2009,12 @@ pluma_document_search_backward (PlumaDocument *doc,
{
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);
+ 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,
@@ -2109,12 +2109,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))
{
@@ -2143,7 +2154,7 @@ pluma_document_replace_all (PlumaDocument *doc,
replace_text_len);
iter = m_start;
- }
+ }
} while (found);