SF.net SVN: geany: [2434] trunk

ntrel at users.sourceforge.net ntrel at xxxxx
Tue Apr 1 13:12:29 UTC 2008


Revision: 2434
          http://geany.svn.sourceforge.net/geany/?rev=2434&view=rev
Author:   ntrel
Date:     2008-04-01 06:12:29 -0700 (Tue, 01 Apr 2008)

Log Message:
-----------
Make navqueue_goto_line() ignore an invalid old document index, and
ignore any documents that don't have a tagmanager work object.
Make Next Error and Next Message commands add positions to the
navqueue, so the user can return to where they were and also so they
can move backwards through error and message items.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/src/msgwindow.c
    trunk/src/navqueue.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2008-04-01 12:53:26 UTC (rev 2433)
+++ trunk/ChangeLog	2008-04-01 13:12:29 UTC (rev 2434)
@@ -4,6 +4,12 @@
    Move Load Tags item from File to Tools menu.
    Capitalize Page Setup item.
    Add separator before Plugin Manager item.
+ * src/navqueue.c, src/msgwindow.c:
+   Make navqueue_goto_line() ignore an invalid old document index, and
+   ignore any documents that don't have a tagmanager work object.
+   Make Next Error and Next Message commands add positions to the
+   navqueue, so the user can return to where they were and also so they
+   can move backwards through error and message items.
 
 
 2008-03-31  Nick Treleaven  <nick(dot)treleaven(at)btinternet(dot)com>

Modified: trunk/src/msgwindow.c
===================================================================
--- trunk/src/msgwindow.c	2008-04-01 12:53:26 UTC (rev 2433)
+++ trunk/src/msgwindow.c	2008-04-01 13:12:29 UTC (rev 2434)
@@ -41,6 +41,7 @@
 #include "build.h"
 #include "main.h"
 #include "vte.h"
+#include "navqueue.h"
 
 #include <string.h>
 #include <stdlib.h>
@@ -477,6 +478,7 @@
 	gchar *string;
 	gboolean ret = FALSE;
 	GdkColor *color;
+	gint old_idx = document_get_cur_idx();
 
 	selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(msgwindow.tree_compiler));
 	if (gtk_tree_selection_get_selected(selection, &model, &iter))
@@ -515,11 +517,12 @@
 				if (idx < 0)	/* file not already open */
 					idx = document_open_file(filename, FALSE, NULL, NULL);
 
-				if (idx >= 0 && doc_list[idx].is_valid)
+				if (DOC_IDX_VALID(idx))
 				{
 					if (! doc_list[idx].changed)	/* if modified, line may be wrong */
 						document_set_indicator(idx, line - 1);
-					ret = utils_goto_line(idx, line);
+
+					ret = navqueue_goto_line(old_idx, idx, line);
 				}
 			}
 			g_free(filename);
@@ -775,13 +778,14 @@
 	selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(msgwindow.tree_msg));
 	if (gtk_tree_selection_get_selected(selection, &model, &iter))
 	{
-		gint idx, line;
+		gint idx, line, old_idx = document_get_cur_idx();
 		gchar *string;
 
 		gtk_tree_model_get(model, &iter, 0, &line, 1, &idx, 3, &string, -1);
 		if (line >= 0 && idx >= 0)
 		{
-			ret = utils_goto_line(idx, line);	/* checks valid idx */
+			if (DOC_IDX_VALID(idx))
+				ret = navqueue_goto_line(old_idx, idx, line);
 		}
 		else if (line < 0 && string != NULL)
 		{
@@ -791,8 +795,8 @@
 			{
 				/* use document_open_file to find an already open file, or open it in place */
 				idx = document_open_file(filename, FALSE, NULL, NULL);
-				/* utils_goto_file_line will check valid filename. */
-				ret = utils_goto_file_line(filename, FALSE, line);
+				if (DOC_IDX_VALID(idx))
+					ret = navqueue_goto_line(old_idx, idx, line);
 			}
 			g_free(filename);
 		}

Modified: trunk/src/navqueue.c
===================================================================
--- trunk/src/navqueue.c	2008-04-01 12:53:26 UTC (rev 2433)
+++ trunk/src/navqueue.c	2008-04-01 13:12:29 UTC (rev 2434)
@@ -134,24 +134,28 @@
 }
 
 
-/* Adds the current document position to the queue before adding the new position.
- * line is counted with 1 as the first line, not 0. */
+/* Adds old file position and new file position to the navqueue, then goes to the new position.
+ * Currently navqueue positions are only be added for documents that have a tagmanager work
+ * object.
+ * @param if old_idx is not valid (e.g. -1), no old position is set.
+ * @param line is counted with 1 as the first line, not 0. */
 gboolean navqueue_goto_line(gint old_idx, gint new_idx, gint line)
 {
-	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 */
-	if (doc_list[old_idx].tm_file)
+	/* first add old file position */
+	if (DOC_IDX_VALID(old_idx) && doc_list[old_idx].tm_file)
 	{
 		gint cur_line = sci_get_current_line(doc_list[old_idx].sci);
 
 		add_new_position(doc_list[old_idx].tm_file->file_name, cur_line + 1);
 	}
 
-	add_new_position(doc_list[new_idx].tm_file->file_name, line);
+	/* now add new file position */
+	if (doc_list[new_idx].tm_file)
+		add_new_position(doc_list[new_idx].tm_file->file_name, line);
+
 	return utils_goto_line(new_idx, line);
 }
 


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