SF.net SVN: geany: [420] trunk

ntrel at users.sourceforge.net ntrel at xxxxx
Wed Jun 7 19:25:29 UTC 2006


Revision: 420
Author:   ntrel
Date:     2006-06-07 12:25:20 -0700 (Wed, 07 Jun 2006)
ViewCVS:  http://svn.sourceforge.net/geany/?rev=420&view=rev

Log Message:
-----------
Use the character position under the mouse click for Go to definition/declaration and for overridden middle click text paste

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/src/callbacks.c
    trunk/src/sciwrappers.c
    trunk/src/sciwrappers.h
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2006-06-07 16:50:41 UTC (rev 419)
+++ trunk/ChangeLog	2006-06-07 19:25:20 UTC (rev 420)
@@ -2,6 +2,9 @@
 
  * src/callbacks.c: Fixed segfault when inserting comments and no
                     filetype is set.
+ * src/callbacks.c, src/sciwrappers.c, src/sciwrappers.h:
+   Use the character position under the mouse click for Go to
+   definition/declaration and for overridden middle click text paste.
 
 
 2006-06-06  Enrico Troeger  <enrico.troeger at uvena.de>

Modified: trunk/src/callbacks.c
===================================================================
--- trunk/src/callbacks.c	2006-06-07 16:50:41 UTC (rev 419)
+++ trunk/src/callbacks.c	2006-06-07 19:25:20 UTC (rev 420)
@@ -964,11 +964,13 @@
                                         GdkEventButton *event,
                                         gpointer user_data)
 {
+	gint idx = GPOINTER_TO_INT(user_data);
+	gint clickpos = sci_get_position_from_xy(doc_list[idx].sci, event->x, event->y, FALSE);
 
 #ifndef GEANY_WIN32
 	if (event->button == 1)
 	{
-		utils_check_disk_status(GPOINTER_TO_INT(user_data));
+		utils_check_disk_status(idx);
 	}
 #endif
 
@@ -979,12 +981,11 @@
 
 		if (gtk_clipboard_wait_is_text_available(cp))
 		{
-			gint idx = document_get_cur_idx();
 			gchar *text = gtk_clipboard_wait_for_text(cp);
 
-			if (idx >= 0 && text != NULL)
+			if (text != NULL)
 			{
-				sci_add_text(doc_list[idx].sci, text);
+				sci_insert_text(doc_list[idx].sci, clickpos, text);
 				g_free(text);
 				return TRUE;
 			}
@@ -993,16 +994,12 @@
 
 	if (event->button == 3)
 	{
-		/// TODO pos should possibly be the position of the mouse pointer instead of the
-		/// current sci position
-		gint pos = sci_get_current_position(doc_list[GPOINTER_TO_INT(user_data)].sci);
+		utils_find_current_word(doc_list[idx].sci, clickpos,
+			current_word, sizeof current_word);
 
-		utils_find_current_word(doc_list[GPOINTER_TO_INT(user_data)].sci, pos,
-					current_word, sizeof current_word);
-
 		utils_update_popup_goto_items((current_word[0] != '\0') ? TRUE : FALSE);
-		utils_update_popup_copy_items(GPOINTER_TO_INT(user_data));
-			utils_update_insert_include_item(GPOINTER_TO_INT(user_data), 0);
+		utils_update_popup_copy_items(idx);
+		utils_update_insert_include_item(idx, 0);
 		gtk_menu_popup(GTK_MENU(app->popup_menu), NULL, NULL, NULL, NULL, event->button, event->time);
 
 		return TRUE;

Modified: trunk/src/sciwrappers.c
===================================================================
--- trunk/src/sciwrappers.c	2006-06-07 16:50:41 UTC (rev 419)
+++ trunk/src/sciwrappers.c	2006-06-07 19:25:20 UTC (rev 420)
@@ -480,6 +480,13 @@
 }
 
 
+gint sci_get_position_from_xy(ScintillaObject* sci, gint x, gint y, gboolean nearby)
+{
+	// for nearby return -1 if there is no character near to the x,y point.
+	return SSM(sci, (nearby) ? SCI_POSITIONFROMPOINTCLOSE : SCI_POSITIONFROMPOINT, x, y);
+}
+
+
 void sci_get_xy_from_position(ScintillaObject* sci,gint pos, gint* x, gint* y)
 {
 	*x = SSM(sci, SCI_POINTXFROMPOSITION,0, (int) pos);

Modified: trunk/src/sciwrappers.h
===================================================================
--- trunk/src/sciwrappers.h	2006-06-07 16:50:41 UTC (rev 419)
+++ trunk/src/sciwrappers.h	2006-06-07 19:25:20 UTC (rev 420)
@@ -81,6 +81,7 @@
 gint 				sci_get_line_length			(ScintillaObject* sci, gint line);
 gint				sci_get_line_count			( ScintillaObject* sci );
 void 				sci_get_xy_from_position	(ScintillaObject* sci,gint pos, gint* x, gint* y);
+gint				sci_get_position_from_xy	(ScintillaObject* sci, gint x, gint y, gboolean nearby);
 
 void 				sci_set_undo_collection		(ScintillaObject* sci, gboolean set);
 gboolean			sci_get_undo_collection		(ScintillaObject* sci);


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