SF.net SVN: geany:[4533] trunk
ntrel at users.sourceforge.net
ntrel at xxxxx
Mon Jan 18 17:05:15 UTC 2010
Revision: 4533
http://geany.svn.sourceforge.net/geany/?rev=4533&view=rev
Author: ntrel
Date: 2010-01-18 17:05:13 +0000 (Mon, 18 Jan 2010)
Log Message:
-----------
Show 'Replaced X matches in Y documents' message when using Replace in
Session.
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/document.c
trunk/src/document.h
trunk/src/search.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2010-01-18 16:57:37 UTC (rev 4532)
+++ trunk/ChangeLog 2010-01-18 17:05:13 UTC (rev 4533)
@@ -2,6 +2,9 @@
* doc/plugins.dox:
Add gcc commands to build a plugin to the HowTo.
+ * src/search.c, src/document.c, src/document.h:
+ Show 'Replaced X matches in Y documents' message when using Replace in
+ Session.
2010-01-17 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
Modified: trunk/src/document.c
===================================================================
--- trunk/src/document.c 2010-01-18 16:57:37 UTC (rev 4532)
+++ trunk/src/document.c 2010-01-18 17:05:13 UTC (rev 4533)
@@ -2278,8 +2278,8 @@
}
-/* returns TRUE if at least one replacement was made. */
-gboolean document_replace_all(GeanyDocument *doc, const gchar *find_text, const gchar *replace_text,
+/* returns number of replacements made. */
+gint document_replace_all(GeanyDocument *doc, const gchar *find_text, const gchar *replace_text,
gint flags, gboolean escaped_chars)
{
gint len, count;
@@ -2293,7 +2293,7 @@
doc, find_text, replace_text, flags, 0, len, TRUE, NULL);
show_replace_summary(doc, count, find_text, replace_text, escaped_chars);
- return (count > 0);
+ return count;
}
Modified: trunk/src/document.h
===================================================================
--- trunk/src/document.h 2010-01-18 16:57:37 UTC (rev 4532)
+++ trunk/src/document.h 2010-01-18 17:05:13 UTC (rev 4533)
@@ -218,7 +218,7 @@
gint document_replace_text(GeanyDocument *doc, const gchar *find_text, const gchar *replace_text,
gint flags, gboolean search_backwards);
-gboolean document_replace_all(GeanyDocument *doc, const gchar *find_text, const gchar *replace_text,
+gint document_replace_all(GeanyDocument *doc, const gchar *find_text, const gchar *replace_text,
gint flags, gboolean escaped_chars);
void document_replace_sel(GeanyDocument *doc, const gchar *find_text, const gchar *replace_text, gint flags,
Modified: trunk/src/search.c
===================================================================
--- trunk/src/search.c 2010-01-18 16:57:37 UTC (rev 4532)
+++ trunk/src/search.c 2010-01-18 17:05:13 UTC (rev 4533)
@@ -1136,23 +1136,33 @@
gint search_flags_re, gboolean search_replace_escape_re,
const gchar *find, const gchar *replace)
{
- guint n, page_count, count = 0;
+ guint n, page_count, rep_count = 0, file_count = 0;
/* replace in all documents following notebook tab order */
page_count = gtk_notebook_get_n_pages(GTK_NOTEBOOK(main_widgets.notebook));
for (n = 0; n < page_count; n++)
{
GeanyDocument *tmp_doc = document_get_from_page(n);
+ gint reps = 0;
- if (document_replace_all(tmp_doc, find, replace, search_flags_re,
- search_replace_escape_re)) count++;
+ reps = document_replace_all(tmp_doc, find, replace, search_flags_re,
+ search_replace_escape_re);
+ rep_count += reps;
+ if (reps)
+ file_count++;
}
- if (count == 0)
+ if (file_count == 0)
+ {
utils_beep();
+ ui_set_statusbar(FALSE, _("No matches found for \"%s\"."), find);
+ return;
+ }
+ /* if only one file was changed, don't override that document's status message
+ * so we don't have to translate 4 messages for ngettext */
+ if (file_count > 1)
+ ui_set_statusbar(FALSE, _("Replaced %u matches in %u documents."),
+ rep_count, file_count);
- ui_set_statusbar(FALSE,
- ngettext("Replaced text in %u file.",
- "Replaced text in %u files.", count), count);
/* show which docs had replacements: */
gtk_notebook_set_current_page(GTK_NOTEBOOK(msgwindow.notebook), MSG_STATUS);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Commits
mailing list