SF.net SVN: geany:[4873] trunk

ntrel at users.sourceforge.net ntrel at xxxxx
Wed May 5 12:51:00 UTC 2010


Revision: 4873
          http://geany.svn.sourceforge.net/geany/?rev=4873&view=rev
Author:   ntrel
Date:     2010-05-05 12:50:59 +0000 (Wed, 05 May 2010)

Log Message:
-----------
Fix replacing {filename} template wildcard for custom file
templates with non-default file extension.
Add search_find_text() for POSIX regex searches.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/doc/geany.html
    trunk/doc/geany.txt
    trunk/src/document.c
    trunk/src/search.c
    trunk/src/search.h

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2010-05-05 12:07:45 UTC (rev 4872)
+++ trunk/ChangeLog	2010-05-05 12:50:59 UTC (rev 4873)
@@ -1,3 +1,12 @@
+2010-05-05  Nick Treleaven  <nick(dot)treleaven(at)btinternet(dot)com>
+
+ * src/search.c, src/search.h, src/document.c, doc/geany.txt,
+   doc/geany.html:
+   Fix replacing {filename} template wildcard for custom file
+   templates with non-default file extension.
+   Add search_find_text() for POSIX regex searches.
+
+
 2010-05-03  Nick Treleaven  <nick(dot)treleaven(at)btinternet(dot)com>
 
  * src/keybindings.c:

Modified: trunk/doc/geany.html
===================================================================
--- trunk/doc/geany.html	2010-05-05 12:07:45 UTC (rev 4872)
+++ trunk/doc/geany.html	2010-05-05 12:50:59 UTC (rev 4873)
@@ -4974,8 +4974,11 @@
 bsd, gpl, snippets.</td>
 </tr>
 <tr><td>filename</td>
-<td>The filename of the current file.</td>
-<td>file header, snippets.</td>
+<td>The filename of the current file.
+Only replaced when first saving if found on
+the first 3 lines of the file.</td>
+<td>file header, snippets, file
+templates.</td>
 </tr>
 <tr><td>gpl</td>
 <td>This wildcard inserts a short GPL notice.</td>
@@ -4996,7 +4999,7 @@
 <td>The file header template. This wildcard
 will only be replaced in filetype
 templates.</td>
-<td>file header, snippets, file.
+<td>file header, snippets, file
 templates.</td>
 </tr>
 <tr><td>command:path</td>
@@ -6008,7 +6011,7 @@
 <div class="footer">
 <hr class="footer" />
 <a class="reference" href="geany.txt">View document source</a>.
-Generated on: 2010-04-28 13:05 UTC.
+Generated on: 2010-05-05 12:43 UTC.
 Generated by <a class="reference" href="http://docutils.sourceforge.net/">Docutils</a> from <a class="reference" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> source.
 
 </div>

Modified: trunk/doc/geany.txt
===================================================================
--- trunk/doc/geany.txt	2010-05-05 12:07:45 UTC (rev 4872)
+++ trunk/doc/geany.txt	2010-05-05 12:50:59 UTC (rev 4873)
@@ -4282,7 +4282,9 @@
                DD.MM.YYYY HH:mm:ss ZZZZ.                     function description, ChangeLog entry,
                                                              bsd, gpl, snippets.
 
-filename       The filename of the current file.             file header, snippets.
+filename       The filename of the current file.             file header, snippets, file
+               Only replaced when first saving if found on   templates.
+               the first 3 lines of the file.
 
 gpl            This wildcard inserts a short GPL notice.     file header.
 
@@ -4293,7 +4295,7 @@
                replaced in the function description.
                template.
 
-fileheader     The file header template. This wildcard       file header, snippets, file.
+fileheader     The file header template. This wildcard       file header, snippets, file
                will only be replaced in filetype             templates.
                templates.
 

Modified: trunk/src/document.c
===================================================================
--- trunk/src/document.c	2010-05-05 12:07:45 UTC (rev 4872)
+++ trunk/src/document.c	2010-05-05 12:50:59 UTC (rev 4873)
@@ -1504,7 +1504,7 @@
 	g_return_if_fail(doc->file_type != NULL);
 
 	if (doc->file_type->extension)
-		filebase = g_strconcat(GEANY_STRING_UNTITLED, ".", doc->file_type->extension, NULL);
+		filebase = g_strconcat(GEANY_STRING_UNTITLED, "\\.\\w+", NULL);
 	else
 		filebase = g_strdup(GEANY_STRING_UNTITLED);
 
@@ -1513,15 +1513,14 @@
 	/* only search the first 3 lines */
 	ttf.chrg.cpMin = 0;
 	ttf.chrg.cpMax = sci_get_position_from_line(doc->editor->sci, 3);
-	ttf.lpstrText = (gchar*)filebase;
+	ttf.lpstrText = filebase;
 
-	if (sci_find_text(doc->editor->sci, SCFIND_MATCHCASE, &ttf) != -1)
+	if (search_find_text(doc->editor->sci, SCFIND_MATCHCASE | SCFIND_REGEXP, &ttf) != -1)
 	{
 		sci_set_target_start(doc->editor->sci, ttf.chrgText.cpMin);
 		sci_set_target_end(doc->editor->sci, ttf.chrgText.cpMax);
 		sci_replace_target(doc->editor->sci, filename, FALSE);
 	}
-
 	g_free(filebase);
 	g_free(filename);
 }

Modified: trunk/src/search.c
===================================================================
--- trunk/src/search.c	2010-05-05 12:07:45 UTC (rev 4872)
+++ trunk/src/search.c	2010-05-05 12:50:59 UTC (rev 4873)
@@ -1763,7 +1763,7 @@
 }
 
 
-static gint search_find_text(ScintillaObject *sci, gint flags, struct Sci_TextToFind *ttf)
+gint search_find_text(ScintillaObject *sci, gint flags, struct Sci_TextToFind *ttf)
 {
 	regex_t regex;
 	gint pos;
@@ -1777,7 +1777,8 @@
 
 	pos = ttf->chrg.cpMin;
 	ret = find_regex(sci, pos, &regex);
-	if (ret >= 0)
+
+	if (ret >= 0 && ret < ttf->chrg.cpMax)
 	{
 		ttf->chrgText.cpMin = regex_matches[0].rm_so + pos;
 		ttf->chrgText.cpMax = regex_matches[0].rm_eo + pos;

Modified: trunk/src/search.h
===================================================================
--- trunk/src/search.h	2010-05-05 12:07:45 UTC (rev 4872)
+++ trunk/src/search.h	2010-05-05 12:50:59 UTC (rev 4873)
@@ -67,10 +67,14 @@
 
 void search_show_find_in_files_dialog(const gchar *dir);
 
+
 struct _ScintillaObject;
+struct Sci_TextToFind;
 
 gint search_find_next(struct _ScintillaObject *sci, const gchar *str, gint flags);
 
+gint search_find_text(struct _ScintillaObject *sci, gint flags, struct Sci_TextToFind *ttf);
+
 void search_find_usage(const gchar *search_text, gint flags, gboolean in_session);
 
 void search_find_selection(GeanyDocument *doc, gboolean search_backwards);
@@ -80,8 +84,6 @@
 gint search_replace_target(struct _ScintillaObject *sci, const gchar *replace_text,
 	gboolean regex);
 
-struct Sci_TextToFind;
-
 guint search_replace_range(struct _ScintillaObject *sci, struct Sci_TextToFind *ttf,
 		gint flags, const gchar *replace_text);
 


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