SF.net SVN: geany: [1900] trunk

ntrel at users.sourceforge.net ntrel at xxxxx
Tue Sep 25 12:39:41 UTC 2007


Revision: 1900
          http://geany.svn.sourceforge.net/geany/?rev=1900&view=rev
Author:   ntrel
Date:     2007-09-25 05:39:41 -0700 (Tue, 25 Sep 2007)

Log Message:
-----------
Fix bug when using Navigate backwards after using the keyboard to
set the cursor position on the current word.
Add symbols_goto_tag().
Replace navqueue_append() with navqueue_goto_line().

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/src/callbacks.c
    trunk/src/keybindings.c
    trunk/src/navqueue.c
    trunk/src/navqueue.h
    trunk/src/symbols.c
    trunk/src/symbols.h
    trunk/src/treeviews.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2007-09-24 16:07:44 UTC (rev 1899)
+++ trunk/ChangeLog	2007-09-25 12:39:41 UTC (rev 1900)
@@ -1,3 +1,13 @@
+2007-09-25  Nick Treleaven  <nick(dot)treleaven(at)btinternet(dot)com>
+
+ * src/keybindings.c, src/navqueue.c, src/navqueue.h, src/treeviews.c,
+   src/callbacks.c, src/symbols.c, src/symbols.h:
+   Fix bug when using Navigate backwards after using the keyboard to
+   set the cursor position on the current word.
+   Add symbols_goto_tag().
+   Replace navqueue_append() with navqueue_goto_line().
+
+
 2007-09-24  Nick Treleaven  <nick(dot)treleaven(at)btinternet(dot)com>
 
  * src/keybindings.c, src/editor.c, src/editor.h:

Modified: trunk/src/callbacks.c
===================================================================
--- trunk/src/callbacks.c	2007-09-24 16:07:44 UTC (rev 1899)
+++ trunk/src/callbacks.c	2007-09-25 12:39:41 UTC (rev 1900)
@@ -1054,41 +1054,14 @@
 on_goto_tag_activate                   (GtkMenuItem     *menuitem,
                                         gpointer         user_data)
 {
-	const gint forward_types = tm_tag_prototype_t | tm_tag_externvar_t;
-	gint type;
-	TMTag *tmtag;
+	gboolean definition = (menuitem ==
+		GTK_MENU_ITEM(lookup_widget(app->popup_menu, "goto_tag_definition1")));
+	document *doc = document_get_current();
 
-	// goto tag definition: all except prototypes / forward declarations / externs
-	if (menuitem == GTK_MENU_ITEM(lookup_widget(app->popup_menu, "goto_tag_definition1")))
-		type = tm_tag_max_t - forward_types;
-	else
-		type = forward_types;
+	g_return_if_fail(doc);
 
-	tmtag = symbols_find_in_workspace(editor_info.current_word, type);
-	if (tmtag != NULL)
-	{
-		gint old_idx = document_get_cur_idx(); // get idx before switching the file
-
-		if (utils_goto_file_line(
-			tmtag->atts.entry.file->work_object.file_name,
-			TRUE, tmtag->atts.entry.line))
-		{
-			// first add old file as old position
-			if (doc_list[old_idx].tm_file)
-				navqueue_new_position(doc_list[old_idx].tm_file->file_name,
-					sci_get_line_from_position(doc_list[old_idx].sci, editor_info.click_pos) + 1);
-
-			navqueue_new_position(tmtag->atts.entry.file->work_object.file_name,
-				tmtag->atts.entry.line);
-			return;
-		}
-	}
-	// if we are here, there was no match and we are beeping ;-)
-	utils_beep();
-	if (type == forward_types)
-		ui_set_statusbar(_("Forward declaration \"%s\" not found."), editor_info.current_word);
-	else
-		ui_set_statusbar(_("Definition of \"%s\" not found."), editor_info.current_word);
+	sci_set_current_position(doc->sci, editor_info.click_pos, FALSE);
+	symbols_goto_tag(editor_info.current_word, definition);
 }
 
 

Modified: trunk/src/keybindings.c
===================================================================
--- trunk/src/keybindings.c	2007-09-24 16:07:44 UTC (rev 1899)
+++ trunk/src/keybindings.c	2007-09-25 12:39:41 UTC (rev 1900)
@@ -42,6 +42,7 @@
 #include "build.h"
 #include "tools.h"
 #include "navqueue.h"
+#include "symbols.h"
 
 
 const gboolean swap_alt_tab_order = FALSE;
@@ -942,12 +943,10 @@
 				on_find_usage1_activate(NULL, NULL);
 				break;
 			case GEANY_KEYS_POPUP_GOTOTAGDEFINITION:
-				on_goto_tag_activate(GTK_MENU_ITEM(lookup_widget(app->popup_menu,
-					"goto_tag_definition1")), NULL);
+				symbols_goto_tag(editor_info.current_word, TRUE);
 				break;
 			case GEANY_KEYS_POPUP_GOTOTAGDECLARATION:
-				on_goto_tag_activate(GTK_MENU_ITEM(lookup_widget(app->popup_menu,
-					"goto_tag_declaration1")), NULL);
+				symbols_goto_tag(editor_info.current_word, FALSE);
 				break;
 			case GEANY_KEYS_POPUP_CONTEXTACTION:
 				on_context_action1_activate(GTK_MENU_ITEM(lookup_widget(app->popup_menu,

Modified: trunk/src/navqueue.c
===================================================================
--- trunk/src/navqueue.c	2007-09-24 16:07:44 UTC (rev 1899)
+++ trunk/src/navqueue.c	2007-09-25 12:39:41 UTC (rev 1900)
@@ -106,7 +106,7 @@
 }
 
 
-void navqueue_new_position(gchar *tm_filename, gint line)
+static void add_new_position(gchar *tm_filename, gint line)
 {
 	filepos *npos;
 	guint i;
@@ -135,12 +135,13 @@
 
 /* Adds the current document position to the queue before adding the new position.
  * line is counted with 1 as the first line, not 0. */
-gboolean navqueue_append(gint new_idx, gint line)
+gboolean navqueue_goto_line(gint new_idx, gint line)
 {
 	gint old_idx = document_get_cur_idx();
 
 	g_return_val_if_fail(DOC_IDX_VALID(old_idx), FALSE);
 	g_return_val_if_fail(DOC_IDX_VALID(new_idx), FALSE);
+	g_return_val_if_fail(doc_list[new_idx].tm_file, FALSE);
 	g_return_val_if_fail(line >= 1, FALSE);
 
 	// first add old file as old position
@@ -148,13 +149,11 @@
 	{
 		gint cur_line = sci_get_current_line(doc_list[old_idx].sci, -1);
 
-		navqueue_new_position(doc_list[old_idx].tm_file->file_name, cur_line + 1);
+		add_new_position(doc_list[old_idx].tm_file->file_name, cur_line + 1);
 	}
 
-	g_return_val_if_fail(doc_list[new_idx].tm_file, FALSE);
-
-	navqueue_new_position(doc_list[new_idx].tm_file->file_name, line);
-	return TRUE;
+	add_new_position(doc_list[new_idx].tm_file->file_name, line);
+	return utils_goto_line(new_idx, line);
 }
 
 

Modified: trunk/src/navqueue.h
===================================================================
--- trunk/src/navqueue.h	2007-09-24 16:07:44 UTC (rev 1899)
+++ trunk/src/navqueue.h	2007-09-25 12:39:41 UTC (rev 1900)
@@ -30,11 +30,8 @@
 void navqueue_free();
 
 
-void navqueue_new_position(gchar *tm_filename, gint line);
+gboolean navqueue_goto_line(gint new_idx, gint line);
 
-gboolean navqueue_append(gint new_idx, gint line);
-
-
 void navqueue_go_back();
 
 void navqueue_go_forward();

Modified: trunk/src/symbols.c
===================================================================
--- trunk/src/symbols.c	2007-09-24 16:07:44 UTC (rev 1899)
+++ trunk/src/symbols.c	2007-09-25 12:39:41 UTC (rev 1900)
@@ -43,6 +43,8 @@
 #include "msgwindow.h"
 #include "treeviews.h"
 #include "main.h"
+#include "navqueue.h"
+#include "ui_utils.h"
 
 
 const guint TM_GLOBAL_TYPE_MASK =
@@ -255,7 +257,7 @@
 }
 
 
-TMTag *symbols_find_in_workspace(const gchar *tag_name, gint type)
+static TMTag *find_workspace_tag(const gchar *tag_name, gint type)
 {
 	guint j;
 	const GPtrArray *tags;
@@ -1035,3 +1037,31 @@
 }
 
 
+gboolean symbols_goto_tag(const gchar *name, gboolean definition)
+{
+	const gint forward_types = tm_tag_prototype_t | tm_tag_externvar_t;
+	gint type;
+	TMTag *tmtag;
+
+	// goto tag definition: all except prototypes / forward declarations / externs
+	type = (definition) ? tm_tag_max_t - forward_types : forward_types;
+
+	tmtag = find_workspace_tag(name, type);
+	if (tmtag != NULL)
+	{
+		gint new_idx = document_find_by_filename(
+			tmtag->atts.entry.file->work_object.file_name, TRUE);
+
+		if (navqueue_goto_line(new_idx, tmtag->atts.entry.line))
+			return TRUE;
+	}
+	// if we are here, there was no match and we are beeping ;-)
+	utils_beep();
+	if (type == forward_types)
+		ui_set_statusbar(_("Forward declaration \"%s\" not found."), name);
+	else
+		ui_set_statusbar(_("Definition of \"%s\" not found."), name);
+	return FALSE;
+}
+
+

Modified: trunk/src/symbols.h
===================================================================
--- trunk/src/symbols.h	2007-09-24 16:07:44 UTC (rev 1899)
+++ trunk/src/symbols.h	2007-09-25 12:39:41 UTC (rev 1900)
@@ -38,8 +38,6 @@
 
 GString *symbols_get_macro_list();
 
-TMTag *symbols_find_in_workspace(const gchar *tag_name, gint type);
-
 const gchar **symbols_get_html_entities();
 
 void symbols_finalize();
@@ -50,4 +48,6 @@
 
 void symbols_show_load_tags_dialog();
 
+gboolean symbols_goto_tag(const gchar *name, gboolean definition);
+
 #endif

Modified: trunk/src/treeviews.c
===================================================================
--- trunk/src/treeviews.c	2007-09-24 16:07:44 UTC (rev 1899)
+++ trunk/src/treeviews.c	2007-09-25 12:39:41 UTC (rev 1900)
@@ -544,8 +544,7 @@
 		{
 			gint idx = document_get_cur_idx();
 
-			navqueue_append(idx, line);
-			utils_goto_line(idx, line);
+			navqueue_goto_line(idx, line);
 		}
 	}
 	return FALSE;


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