SF.net SVN: geany: [640] trunk

ntrel at users.sourceforge.net ntrel at xxxxx
Wed Jul 26 17:10:42 UTC 2006


Revision: 640
Author:   ntrel
Date:     2006-07-26 10:10:35 -0700 (Wed, 26 Jul 2006)
ViewCVS:  http://svn.sourceforge.net/geany/?rev=640&view=rev

Log Message:
-----------
Only replace untitled.x within the first 2 lines

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/src/utils.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2006-07-26 17:02:16 UTC (rev 639)
+++ trunk/ChangeLog	2006-07-26 17:10:35 UTC (rev 640)
@@ -19,6 +19,7 @@
                 hide the prefs option to show them.
  * src/main.c: Disable the Compiler tab instead of hiding it so that
                messages window tabs have the right index on switching.
+ * src/utils.c: Only replace untitled.x within the first 2 lines.
 
 
 2006-07-25  Enrico Tröger  <enrico.troeger at uvena.de>

Modified: trunk/src/utils.c
===================================================================
--- trunk/src/utils.c	2006-07-26 17:02:16 UTC (rev 639)
+++ trunk/src/utils.c	2006-07-26 17:10:35 UTC (rev 640)
@@ -1866,31 +1866,29 @@
 
 void utils_replace_filename(gint idx)
 {
-	gint pos;
 	gchar *filebase;
 	gchar *filename;
+	struct TextToFind ttf;
 
 	if (idx == -1 || doc_list[idx].file_type == NULL) return;
 
-	pos = sci_get_current_position(doc_list[idx].sci);
 	filebase = g_strconcat(GEANY_STRING_UNTITLED, ".", (doc_list[idx].file_type)->extension, NULL);
 	filename = g_path_get_basename(doc_list[idx].file_name);
 
-	sci_set_current_position(doc_list[idx].sci, 0);
-	sci_set_search_anchor(doc_list[idx].sci);
-	// stop if filebase was not found
-	if (sci_search_next(doc_list[idx].sci, SCFIND_MATCHCASE, filebase) == -1)
+	// only search the first 2 lines
+	ttf.chrg.cpMin = 0;
+	ttf.chrg.cpMax = sci_get_position_from_line(doc_list[idx].sci, 2);
+	ttf.lpstrText = (gchar*)filebase;
+
+	if (sci_find_text(doc_list[idx].sci, SCFIND_MATCHCASE, &ttf) != -1)
 	{
-		g_free(filebase);
-		g_free(filename);
-		return;
+		sci_target_start(doc_list[idx].sci, ttf.chrgText.cpMin);
+		sci_target_end(doc_list[idx].sci, ttf.chrgText.cpMax);
+		sci_target_replace(doc_list[idx].sci, filename, FALSE);
 	}
 
-	sci_replace_sel(doc_list[idx].sci, filename);
 	g_free(filebase);
 	g_free(filename);
-
-	sci_set_current_position(doc_list[idx].sci, pos);
 }
 
 


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