Kaydet (Commit) a59a4ae0 authored tarafından Nick Treleaven's avatar Nick Treleaven

Don't open files or go to errors automatically whilst compiling. Rename…

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

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@462 ea778897-0a13-0410-b9d1-a72fbfd435f5
üst f8c92268
2006-06-19 Nick Treleaven <nick.treleaven@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@uvena.de>
* src/keybindings.c: Fixed a segfault when pressing shortcut for
......
......@@ -449,7 +449,6 @@ static gboolean build_iofunc(GIOChannel *ioc, GIOCondition cond, gpointer data)
//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 @@ static gboolean build_iofunc(GIOChannel *ioc, GIOCondition cond, gpointer data)
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
......
......@@ -1304,7 +1304,7 @@ on_goto_tag_activate (GtkMenuItem *menuitem,
{
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 @@ on_tree_view_button_press_event (GtkWidget *widget,
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 @@ on_tree_view_button_press_event (GtkWidget *widget,
{
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);
}
......
......@@ -447,7 +447,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)
{
gint page_num;
gint file_idx = document_find_by_filename(file, is_tm_filename);
......@@ -2299,22 +2299,22 @@ gdouble utils_strtod(const gchar *source, gchar **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)
{
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 @@ void utils_parse_compiler_error_line(const gchar *string, gint *idx_of_error_fil
// 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);
}
......@@ -59,7 +59,7 @@ const GList *utils_get_tag_list(gint idx, guint tag_types);
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 @@ void utils_update_fold_items(void);
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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment