SF.net SVN: geany: [613] trunk

eht16 at users.sourceforge.net eht16 at xxxxx
Sun Jul 23 20:27:05 UTC 2006


Revision: 613
Author:   eht16
Date:     2006-07-23 13:26:57 -0700 (Sun, 23 Jul 2006)
ViewCVS:  http://svn.sourceforge.net/geany/?rev=613&view=rev

Log Message:
-----------
Let Find usage search for the current selection if there is one.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/src/callbacks.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2006-07-23 16:00:46 UTC (rev 612)
+++ trunk/ChangeLog	2006-07-23 20:26:57 UTC (rev 613)
@@ -4,6 +4,8 @@
  * src/documents.c: Fixed some mistakes from last commit.
  * src/dialogs.c, src/utils.c, src/document.c, src/geany.h:
    Renamed document element unicode_bom in has_bom.
+ * src/callbacks.c:
+   Let Find usage search for the current selection if there is one.
 
 
 2006-07-22  Nick Treleaven  <nick.treleaven at btinternet.com>

Modified: trunk/src/callbacks.c
===================================================================
--- trunk/src/callbacks.c	2006-07-23 16:00:46 UTC (rev 612)
+++ trunk/src/callbacks.c	2006-07-23 20:26:57 UTC (rev 613)
@@ -1331,19 +1331,30 @@
 {
 	gint i, pos, line = -1;
 	gint flags = SCFIND_MATCHCASE | SCFIND_WHOLEWORD;
+	gint idx;
 	struct TextToFind ttf;
-	gchar *buffer, *short_file_name, *string;
+	gchar *buffer, *short_file_name, *string, *search_text;
 
 	gtk_notebook_set_current_page(GTK_NOTEBOOK(msgwindow.notebook), MSG_MESSAGE);
 	gtk_list_store_clear(msgwindow.store_msg);
+
+	idx = document_get_cur_idx();
+	if (sci_can_copy(doc_list[idx].sci))
+	{	// take selected text if there is a selection
+		search_text = g_malloc(sci_get_selected_text_length(doc_list[idx].sci) + 1);
+		sci_get_selected_text(doc_list[idx].sci, search_text);
+	}
+	else
+		search_text = g_strdup(current_word);
+
 	for(i = 0; i < GEANY_MAX_OPEN_FILES; i++)
 	{
 		if (doc_list[i].is_valid)
 		{
 			ttf.chrg.cpMin = 0;
 			ttf.chrg.cpMax = sci_get_length(doc_list[i].sci);
-			ttf.lpstrText = g_malloc(sizeof current_word);
-			strncpy(ttf.lpstrText, current_word, sizeof current_word);
+			ttf.lpstrText = g_malloc(sizeof search_text);
+			strncpy(ttf.lpstrText, search_text, sizeof search_text);
 			while (1)
 			{
 				pos = sci_find_text(doc_list[i].sci, flags, &ttf);
@@ -1369,7 +1380,9 @@
 		}
 	}
 	if (line == -1) // no matches were found (searching from unnamed file)
-		msgwin_status_add(_("No matches found for '%s'."), current_word);
+		msgwin_status_add(_("No matches found for '%s'."), search_text);
+
+	g_free(search_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