SF.net SVN: geany:[5428] trunk

ntrel at users.sourceforge.net ntrel at xxxxx
Tue Nov 23 13:17:42 UTC 2010


Revision: 5428
          http://geany.svn.sourceforge.net/geany/?rev=5428&view=rev
Author:   ntrel
Date:     2010-11-23 13:17:42 +0000 (Tue, 23 Nov 2010)

Log Message:
-----------
If the current word's tag is on the current line, make Go to Tag
Definition look for a tag declaration instead, as this is more
useful. Likewise make Go to Tag Declaration search for a tag
definition in this case also.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/doc/geany.html
    trunk/doc/geany.txt
    trunk/src/symbols.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2010-11-23 12:50:24 UTC (rev 5427)
+++ trunk/ChangeLog	2010-11-23 13:17:42 UTC (rev 5428)
@@ -3,6 +3,11 @@
  * src/interface.c, src/keybindings.c, src/callbacks.c,
    src/callbacks.h, geany.glade:
    Add 'Mark All' Search menu command.
+ * src/symbols.c, doc/geany.txt, doc/geany.html:
+   If the current word's tag is on the current line, make Go to Tag
+   Definition look for a tag declaration instead, as this is more
+   useful. Likewise make Go to Tag Declaration search for a tag
+   definition in this case also.
 
 
 2010-11-22  Nick Treleaven  <nick(dot)treleaven(at)btinternet(dot)com>

Modified: trunk/doc/geany.html
===================================================================
--- trunk/doc/geany.html	2010-11-23 12:50:24 UTC (rev 5427)
+++ trunk/doc/geany.html	2010-11-23 13:17:42 UTC (rev 5428)
@@ -6,7 +6,7 @@
 <meta name="generator" content="Docutils 0.4: http://docutils.sourceforge.net/" />
 <title>Geany</title>
 <meta name="authors" content="Enrico Tröger  Nick Treleaven  Frank Lanitz" />
-<meta name="date" content="2010-11-17" />
+<meta name="date" content="2010-11-22" />
 <style type="text/css">
 
 /*
@@ -139,7 +139,7 @@
 <br />Nick Treleaven
 <br />Frank Lanitz</td></tr>
 <tr><th class="docinfo-name">Date:</th>
-<td>2010-11-17</td></tr>
+<td>2010-11-22</td></tr>
 <tr><th class="docinfo-name">Version:</th>
 <td>0.20</td></tr>
 </tbody>
@@ -1732,7 +1732,14 @@
 current word is either the word nearest the edit cursor,
 or the word underneath the popup menu click position when the popup
 menu is used.</p>
+<div class="note">
+<p class="first admonition-title">Note</p>
+<p class="last">If the current word's tag is on the current line, Geany will try
+to look for a tag declaration instead, as this is more useful.
+Likewise 'Go to tag declaration' will search for a tag definition
+in this case also.</p>
 </div>
+</div>
 <div class="section">
 <h3><a class="toc-backref" href="#id73" id="go-to-tag-declaration" name="go-to-tag-declaration">Go to tag declaration</a></h3>
 <p>Like Go to tag definition, but for a forward declaration such as a
@@ -6359,7 +6366,7 @@
 <div class="footer">
 <hr class="footer" />
 <a class="reference" href="geany.txt">View document source</a>.
-Generated on: 2010-11-22 12:42 UTC.
+Generated on: 2010-11-23 13:12 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-11-23 12:50:24 UTC (rev 5427)
+++ trunk/doc/geany.txt	2010-11-23 13:17:42 UTC (rev 5428)
@@ -1357,7 +1357,13 @@
 or the word underneath the popup menu click position when the popup
 menu is used.
 
+.. note::
+    If the current word's tag is on the current line, Geany will try
+    to look for a tag declaration instead, as this is more useful.
+    Likewise 'Go to tag declaration' will search for a tag definition
+    in this case also.
 
+
 Go to tag declaration
 ^^^^^^^^^^^^^^^^^^^^^
 

Modified: trunk/src/symbols.c
===================================================================
--- trunk/src/symbols.c	2010-11-23 12:50:24 UTC (rev 5427)
+++ trunk/src/symbols.c	2010-11-23 13:17:42 UTC (rev 5428)
@@ -1542,7 +1542,7 @@
 }
 
 
-gboolean symbols_goto_tag(const gchar *name, gboolean definition)
+static gboolean goto_tag(const gchar *name, gboolean definition)
 {
 	const gint forward_types = tm_tag_prototype_t | tm_tag_externvar_t;
 	gint type;
@@ -1565,18 +1565,38 @@
 		GeanyDocument *new_doc = document_find_by_real_path(
 			tmtag->atts.entry.file->work_object.file_name);
 
-		/* not found in opened document, should open */
-		if (new_doc == NULL)
+		if (new_doc)
 		{
+			/* If we are already on the tag line, swap definition/declaration */
+			if (new_doc == old_doc &&
+				tmtag->atts.entry.line == (guint)sci_get_current_line(old_doc->editor->sci) + 1)
+			{
+				if (goto_tag(name, !definition))
+					return TRUE;
+			}
+		}
+		else
+		{
+			/* not found in opened document, should open */
 			new_doc = document_open_file(tmtag->atts.entry.file->work_object.file_name, FALSE, NULL, NULL);
 		}
 
 		if (navqueue_goto_line(old_doc, new_doc, tmtag->atts.entry.line))
 			return TRUE;
 	}
+	return FALSE;
+}
+
+
+gboolean symbols_goto_tag(const gchar *name, gboolean definition)
+{
+	if (goto_tag(name, definition))
+		return TRUE;
+
 	/* if we are here, there was no match and we are beeping ;-) */
 	utils_beep();
-	if (type == forward_types)
+
+	if (!definition)
 		ui_set_statusbar(FALSE, _("Forward declaration \"%s\" not found."), name);
 	else
 		ui_set_statusbar(FALSE, _("Definition of \"%s\" not found."), name);


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