SF.net SVN: geany: [462] trunk

ntrel at users.sourceforge.net ntrel at xxxxx
Mon Jun 19 13:27:19 UTC 2006


Revision: 462
Author:   ntrel
Date:     2006-06-19 06:27:09 -0700 (Mon, 19 Jun 2006)
ViewCVS:  http://svn.sourceforge.net/geany/?rev=462&view=rev

Log Message:
-----------
Don't open files or go to errors automatically whilst compiling. Rename utils_goto_workspace_tag to utils_goto_file_line

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/src/build.c
    trunk/src/callbacks.c
    trunk/src/utils.c
    trunk/src/utils.h
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2006-06-18 20:21:19 UTC (rev 461)
+++ trunk/ChangeLog	2006-06-19 13:27:09 UTC (rev 462)
@@ -1,3 +1,10 @@
+2006-06-19  Nick Treleaven  <nick.treleaven at btinternet.com>
+
+ * src/build.c, src/utils.c, src/utils.h, src/callbacks.c:
+   Don't open files or go to errors automatically whilst compiling.
+   Rename utils_goto_workspace_tag to utils_goto_file_line.
+
+
 2006-06-18  Enrico Troeger  <enrico.troeger at uvena.de>
 
  * src/keybindings.c: Fixed a segfault when pressing shortcut for

Modified: trunk/src/build.c
===================================================================
--- trunk/src/build.c	2006-06-18 20:21:19 UTC (rev 461)
+++ trunk/src/build.c	2006-06-19 13:27:09 UTC (rev 462)
@@ -449,7 +449,6 @@
 		//GIOStatus s;
 		gchar *msg;
 		guint x = 1;
-		gint line, idx;
 
 		while (g_io_channel_read_line(ioc, &msg, NULL, NULL, NULL) && msg)
 		{
@@ -459,8 +458,16 @@
 				msgwin_compiler_add(COLOR_RED, FALSE, g_strstrip(msg));
 				if (app->pref_editor_use_indicators)
 				{
-					utils_parse_compiler_error_line(g_strstrip(msg), &idx, &line);
-					if (line != -1) document_set_indicator(idx, line - 1);				
+					gchar *filename;
+					gint line;
+					utils_parse_compiler_error_line(g_strstrip(msg), &filename, &line);
+					if (line != -1)
+					{
+						gint idx = document_find_by_filename(filename, FALSE);
+						// document_set_indicator will check valid idx
+						document_set_indicator(idx, line - 1);
+					}
+					g_free(filename);
 				}
 			}
 			else

Modified: trunk/src/callbacks.c
===================================================================
--- trunk/src/callbacks.c	2006-06-18 20:21:19 UTC (rev 461)
+++ trunk/src/callbacks.c	2006-06-19 13:27:09 UTC (rev 462)
@@ -1304,7 +1304,7 @@
 			{
 				if (utils_strcmp(TM_TAG(tags->pdata[i])->name, current_word))
 				{
-					if (! utils_goto_workspace_tag(
+					if (! utils_goto_file_line(
 							TM_TAG(tags->pdata[i])->atts.entry.file->work_object.file_name,
 							TRUE,
 							TM_TAG(tags->pdata[i])->atts.entry.line))
@@ -1361,7 +1361,7 @@
 				gtk_tree_model_get(model, &iter, 0, &line, 1, &file, -1);
 				if (file && strlen (file) > 0)
 				{
-					utils_goto_workspace_tag(file, FALSE, line);
+					utils_goto_file_line(file, FALSE, line);
 				}
 				g_free(file);
 			}
@@ -1383,8 +1383,18 @@
 				{
 					gint line;
 					gint idx;
-					utils_parse_compiler_error_line(string, &idx, &line);
-					if (idx != -1 && line != -1) utils_goto_line(idx, line);
+					gchar *filename;
+					utils_parse_compiler_error_line(string, &filename, &line);
+					if (filename != NULL && line > -1)
+					{
+						// use document_open_file to find an already open file, or open it in place
+						idx = document_open_file(-1, filename, 0, FALSE, NULL);
+						// document_set_indicator will check valid idx
+						document_set_indicator(idx, line - 1);
+						// utils_goto_file_line will check valid filename.
+						utils_goto_file_line(filename, FALSE, line);
+					}
+					g_free(filename);
 				}
 				g_free(string);
 			}

Modified: trunk/src/utils.c
===================================================================
--- trunk/src/utils.c	2006-06-18 20:21:19 UTC (rev 461)
+++ trunk/src/utils.c	2006-06-19 13:27:09 UTC (rev 462)
@@ -447,7 +447,7 @@
 }
 
 
-gboolean utils_goto_workspace_tag(const gchar *file, gboolean is_tm_filename, gint line)
+gboolean utils_goto_file_line(const gchar *file, gboolean is_tm_filename, gint line)
 {
 	gint page_num;
 	gint file_idx = document_find_by_filename(file, is_tm_filename);
@@ -2299,22 +2299,22 @@
 
 
 /* try to parse the file and line number where the error occured described in line
- * and when something useful is found, it stores the line number in *line and the index of
- * the file in *idx_of_error_file. */
-void utils_parse_compiler_error_line(const gchar *string, gint *idx_of_error_file, gint *line)
+ * and when something useful is found, it stores the line number in *line and the
+ * relevant file with the error in *filename.
+ * *line will be -1 if no error was found in string.
+ * *filename must be freed unless it is NULL. */
+void utils_parse_compiler_error_line(const gchar *string, gchar **filename, gint *line)
 {
-	gint idx = document_get_cur_idx();
 	gchar *end = NULL;
 	gchar *path;
-	gchar *filename;
 	gchar **fields;
 	gchar *pattern;			// pattern to split the error message into some fields
 	guint field_min_len;	// used to detect errors after parsing
 	guint field_idx_line;	// idx of the field where the line is
 	guint field_idx_file;	// idx of the field where the filename is
 	
+	*filename = NULL;
 	*line = -1;
-	*idx_of_error_file = -1;
 
 	if (string == NULL || ! doc_list[app->cur_idx].is_valid ||
 		doc_list[app->cur_idx].file_type == NULL)
@@ -2399,20 +2399,8 @@
 
 	// get the basename of the built file to get the path to look for other files
 	path = g_path_get_dirname(doc_list[app->cur_idx].file_name);
-	filename = g_strconcat(path, G_DIR_SEPARATOR_S, fields[field_idx_file], NULL);
-
-	// use document_open_file to find an already opened file, or to open it in place
-	*idx_of_error_file = document_open_file(-1, filename, 0, FALSE, NULL);
-
+	*filename = g_strconcat(path, G_DIR_SEPARATOR_S, fields[field_idx_file], NULL);
 	g_free(path);
-	g_free(filename);
 
-	if (*idx_of_error_file != -1 && doc_list[*idx_of_error_file].is_valid &&
-		*line == -1 && idx != *idx_of_error_file)
-	{
-		gtk_notebook_set_current_page(GTK_NOTEBOOK(app->notebook),
-							gtk_notebook_page_num(GTK_NOTEBOOK(app->notebook),
-							GTK_WIDGET(doc_list[*idx_of_error_file].sci)));
-	}
 	g_strfreev(fields);
 }

Modified: trunk/src/utils.h
===================================================================
--- trunk/src/utils.h	2006-06-18 20:21:19 UTC (rev 461)
+++ trunk/src/utils.h	2006-06-19 13:27:09 UTC (rev 462)
@@ -59,7 +59,7 @@
 
 gint utils_get_local_tag(gint idx, const gchar *qual_name);
 
-gboolean utils_goto_workspace_tag(const gchar *file, gboolean is_tm_filename, gint line);
+gboolean utils_goto_file_line(const gchar *file, gboolean is_tm_filename, gint line);
 
 gboolean utils_goto_line(gint idx, gint line);
 
@@ -207,8 +207,10 @@
 double utils_strtod(const char *source, char **end);
 
 /* try to parse the file and line number where the error occured described in line
- * and when something useful is found, it stores the line number in *line and the index of
- * the file in *idx_of_error_file. */
-void utils_parse_compiler_error_line(const gchar *string, gint *idx_of_error_file, gint *line);
+ * and when something useful is found, it stores the line number in *line and the
+ * relevant file with the error in filename.
+ * *line will be -1 if no error was found in string.
+ * filename must be freed unless it is NULL. */
+void utils_parse_compiler_error_line(const gchar *string, gchar **filename, gint *line);
 
 #endif


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