Hi guys,

My name is Shankhoneer Chakrovarty (aka 'shankhs' ), I have been using
geany for past 3-4 years (mainly on my ubuntu ) and I have learned all my
programming skills on geany. So thank you!

Since I have been programming for 3-4 years now and also using geany, I
thought it will be great if I could give something back to the geany
community.

I pulled the geany source code, read the HACKING file and created a patch
which categorizes the compiler errors into "error" and "warning" and
correspondingly draws a different colored squiggle underline in the line
which caused the error. I have created the patch as mentioned in the
hacking file and attached with this mail.
If you guys have some time, can you please review the patch? If you need
any more info, please feel free to drop me an email, I will be more than
happy to explain it.

Also, I am reading the geany source code and modified some part of it to
suit my personal needs so if you need a hand in resolving bugs, please do
tell me. I am particularly interested in
https://sourceforge.net/p/geany/bugs/254/ .

Thanks,
Shankhoneer Chakrivarty
From ec8fff9c2560533764c8e19b3e6fe61da1a59757 Mon Sep 17 00:00:00 2001
From: shankhs <shankhol...@gmail.com>
Date: Tue, 11 Mar 2014 01:27:12 -0700
Subject: [PATCH] Added new colored underline scheme for cpp type files

In case of statements causing warning in gcc instead of error
they will be underlined in blue instead of red.
---
 src/build.c        | 19 +++++++++++++------
 src/editor.c       |  3 ++-
 src/editor.h       |  2 ++
 src/filetypes.c    |  1 -
 src/highlighting.c |  4 ++++
 src/msgwindow.c    | 27 +++++++++++++++------------
 src/msgwindow.h    |  2 +-
 7 files changed, 37 insertions(+), 21 deletions(-)

diff --git a/src/build.c b/src/build.c
index 07e18ea..aff7328 100644
--- a/src/build.c
+++ b/src/build.c
@@ -62,7 +62,6 @@
 #include "toolbar.h"
 #include "geanymenubuttonaction.h"
 #include "gtkcompat.h"
-
 /* g_spawn_async_with_pipes doesn't work on Windows */
 #ifdef G_OS_WIN32
 #define SYNC_SPAWN
@@ -879,7 +878,7 @@ static gchar *prepare_run_script(GeanyDocument *doc, gchar **vte_cmd_nonscript,
 	gchar *tmp;
 	gchar *cmd_string;
 	GError *error = NULL;
-
+	
 	if (vte_cmd_nonscript != NULL)
 		*vte_cmd_nonscript = NULL;
 
@@ -890,7 +889,6 @@ static gchar *prepare_run_script(GeanyDocument *doc, gchar **vte_cmd_nonscript,
 	if (EMPTY(cmd_working_dir))
 		cmd_working_dir = "%d";
 	working_dir = build_replace_placeholder(doc, cmd_working_dir); /* in utf-8 */
-
 	/* only test whether working dir exists, don't change it or else Windows support will break
 	 * (gspawn-win32-helper.exe is used by GLib and must be in $PATH which means current working
 	 *  dir where geany.exe was started from, so we can't change it) */
@@ -923,6 +921,7 @@ static gchar *prepare_run_script(GeanyDocument *doc, gchar **vte_cmd_nonscript,
 
 	/* RUN_SCRIPT_CMD should be ok in UTF8 without converting in locale because it
 	 * contains no umlauts */
+	 
 	tmp = g_build_filename(working_dir, RUN_SCRIPT_CMD, NULL);
 	result = build_create_shellscript(tmp, cmd_string, autoclose, &error);
 	if (! result)
@@ -1075,6 +1074,8 @@ static void process_build_output_line(const gchar *str, gint color)
 	gchar *msg, *tmp;
 	gchar *filename;
 	gint line;
+	gchar *type;
+	const gchar *warning = "warning";
 
 	msg = g_strdup(str);
 
@@ -1090,7 +1091,7 @@ static void process_build_output_line(const gchar *str, gint color)
 	{
 		SETPTR(current_dir_entered, tmp);
 	}
-	msgwin_parse_compiler_error_line(msg, current_dir_entered, &filename, &line);
+	msgwin_parse_compiler_error_line(msg, current_dir_entered, &filename, &line,&type);
 
 	if (line != -1 && filename != NULL)
 	{
@@ -1102,7 +1103,14 @@ static void process_build_output_line(const gchar *str, gint color)
 		{
 			if (line > 0) /* some compilers, like pdflatex report errors on line 0 */
 				line--;   /* so only adjust the line number if it is greater than 0 */
-			editor_indicator_set_on_line(doc->editor, GEANY_INDICATOR_ERROR, line);
+			if(type != NULL && g_ascii_strcasecmp(type,warning)==0)
+			{
+				editor_indicator_set_on_line(doc->editor, GEANY_INDICATOR_WARNING, line);
+			}
+			else
+			{
+				editor_indicator_set_on_line(doc->editor, GEANY_INDICATOR_ERROR, line);
+			}
 		}
 		build_info.message_count++;
 		color = COLOR_RED;	/* error message parsed on the line */
@@ -2818,7 +2826,6 @@ void build_init(void)
 	GtkWidget *item;
 	GtkWidget *toolmenu;
 	gint cmdindex;
-
 	g_signal_connect(geany_object, "project-close", on_project_close, NULL);
 
 	ft_def = g_new0(GeanyBuildCommand, build_groups_count[GEANY_GBG_FT]);
diff --git a/src/editor.c b/src/editor.c
index 0db81c4..4d5da61 100644
--- a/src/editor.c
+++ b/src/editor.c
@@ -1484,7 +1484,6 @@ static void auto_close_chars(ScintillaObject *sci, gint pos, gchar c)
 				closing_char = "\"";
 			break;
 	}
-
 	if (closing_char != NULL)
 	{
 		sci_add_text(sci, closing_char);
@@ -4053,6 +4052,8 @@ void editor_display_current_line(GeanyEditor *editor, gfloat percent_of_view)
 void editor_indicator_clear_errors(GeanyEditor *editor)
 {
 	editor_indicator_clear(editor, GEANY_INDICATOR_ERROR);
+	/** This is bluish squiggly yellow line */
+	editor_indicator_clear(editor, GEANY_INDICATOR_WARNING);
 	sci_marker_delete_all(editor->sci, 0);	/* remove the yellow error line marker */
 }
 
diff --git a/src/editor.h b/src/editor.h
index 9a9f1c7..d7f15e7 100644
--- a/src/editor.h
+++ b/src/editor.h
@@ -75,6 +75,8 @@ typedef enum
 {
 	/** Indicator to highlight errors in the document text. This is a red squiggly underline. */
 	GEANY_INDICATOR_ERROR = 0,
+	/** Indicator to highlight warning in the document text. This should be yellow squiggly line */
+	GEANY_INDICATOR_WARNING = 1,
 	/** Indicator used to highlight search results in the document. This is a
 	 *  rounded box around the text. */
 	/* start container indicator outside of lexer indicators (0..7), see Scintilla docs */
diff --git a/src/filetypes.c b/src/filetypes.c
index 4650c2b..393143d 100644
--- a/src/filetypes.c
+++ b/src/filetypes.c
@@ -1268,7 +1268,6 @@ gboolean filetypes_parse_error_message(GeanyFiletype *ft, const gchar *message,
 	if (tmp == NULL)
 		return FALSE;
 	regstr = *tmp;
-
 	*filename = NULL;
 	*line = -1;
 
diff --git a/src/highlighting.c b/src/highlighting.c
index 073acef..d8e1660 100644
--- a/src/highlighting.c
+++ b/src/highlighting.c
@@ -663,6 +663,10 @@ static void styleset_common(ScintillaObject *sci, guint ft_id)
 	/* Error indicator */
 	SSM(sci, SCI_INDICSETSTYLE, GEANY_INDICATOR_ERROR, INDIC_SQUIGGLEPIXMAP);
 	SSM(sci, SCI_INDICSETFORE, GEANY_INDICATOR_ERROR, invert(0x0000FF /* red, in BGR */));
+	/* Warning indicator */
+	SSM(sci, SCI_INDICSETSTYLE, GEANY_INDICATOR_WARNING, INDIC_SQUIGGLEPIXMAP);
+	SSM(sci, SCI_INDICSETFORE, GEANY_INDICATOR_WARNING, (0xA52A2A /* yellow, in BGR */));
+
 
 	/* Search indicator, used for 'Mark' matches */
 	SSM(sci, SCI_INDICSETSTYLE, GEANY_INDICATOR_SEARCH, INDIC_ROUNDBOX);
diff --git a/src/msgwindow.c b/src/msgwindow.c
index f423267..e351be3 100644
--- a/src/msgwindow.c
+++ b/src/msgwindow.c
@@ -692,6 +692,7 @@ gboolean msgwin_goto_compiler_file_line(gboolean focus_editor)
 	GtkTreeSelection *selection;
 	gchar *string;
 	GdkColor *color;
+	gchar *type;
 
 	selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(msgwindow.tree_compiler));
 	if (gtk_tree_selection_get_selected(selection, &model, &iter))
@@ -717,7 +718,7 @@ gboolean msgwin_goto_compiler_file_line(gboolean focus_editor)
 			path = gtk_tree_model_get_path(model, &iter);
 			find_prev_build_dir(path, model, &dir);
 			gtk_tree_path_free(path);
-			msgwin_parse_compiler_error_line(string, dir, &filename, &line);
+			msgwin_parse_compiler_error_line(string, dir, &filename, &line,&type);
 			g_free(string);
 			g_free(dir);
 
@@ -753,7 +754,7 @@ static void make_absolute(gchar **filename, const gchar *dir)
  * 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. */
-static void parse_file_line(ParseData *data, gchar **filename, gint *line)
+static void parse_file_line(ParseData *data, gchar **filename, gint *line, gchar **type)
 {
 	gchar *end = NULL;
 	gchar **fields;
@@ -762,18 +763,20 @@ static void parse_file_line(ParseData *data, gchar **filename, gint *line)
 	*line = -1;
 
 	g_return_if_fail(data->string != NULL);
-
 	fields = g_strsplit_set(data->string, data->pattern, data->min_fields);
-
 	/* parse the line */
 	if (g_strv_length(fields) < data->min_fields)
 	{
 		g_strfreev(fields);
 		return;
 	}
-
+	
 	*line = strtol(fields[data->line_idx], &end, 10);
-
+	if (g_strv_length(fields) == data->min_fields)
+	{
+		*type = g_strstrip(g_strdup(fields[data->line_idx+2]));
+	}
+	
 	/* if the line could not be read, line is 0 and an error occurred, so we leave */
 	if (fields[data->line_idx] == end)
 	{
@@ -798,7 +801,7 @@ static void parse_file_line(ParseData *data, gchar **filename, gint *line)
 
 
 static void parse_compiler_error_line(const gchar *string,
-		gchar **filename, gint *line)
+		gchar **filename, gint *line, gchar **type)
 {
 	ParseData data = {NULL, NULL, 0, 0, 0};
 
@@ -961,16 +964,15 @@ static void parse_compiler_error_line(const gchar *string,
 			if (strstr(string, "libtool --mode=link") == NULL)
 			{
 				data.pattern = ":";
-				data.min_fields = 3;
+				data.min_fields = 5;
 				data.line_idx = 1;
 				data.file_idx = 0;
 				break;
 			}
 		}
 	}
-
 	if (data.pattern != NULL)
-		parse_file_line(&data, filename, line);
+		parse_file_line(&data, filename, line,type);
 }
 
 
@@ -980,13 +982,14 @@ static void parse_compiler_error_line(const gchar *string,
  * *line will be -1 if no error was found in string.
  * *filename must be freed unless it is NULL. */
 void msgwin_parse_compiler_error_line(const gchar *string, const gchar *dir,
-		gchar **filename, gint *line)
+		gchar **filename, gint *line, gchar **type)
 {
 	GeanyFiletype *ft;
 	gchar *trimmed_string;
 
 	*filename = NULL;
 	*line = -1;
+	*type = NULL;
 
 	if (G_UNLIKELY(string == NULL))
 		return;
@@ -1004,7 +1007,7 @@ void msgwin_parse_compiler_error_line(const gchar *string, const gchar *dir,
 	if (!filetypes_parse_error_message(ft, trimmed_string, filename, line))
 	{
 		/* fallback to default old-style parsing */
-		parse_compiler_error_line(trimmed_string, filename, line);
+		parse_compiler_error_line(trimmed_string, filename, line,type);
 	}
 	make_absolute(filename, dir);
 	g_free(trimmed_string);
diff --git a/src/msgwindow.h b/src/msgwindow.h
index 18f487f..244418d 100644
--- a/src/msgwindow.h
+++ b/src/msgwindow.h
@@ -98,7 +98,7 @@ void msgwin_menu_add_common_items(GtkMenu *menu);
 gboolean msgwin_goto_compiler_file_line(gboolean focus_editor);
 
 void msgwin_parse_compiler_error_line(const gchar *string, const gchar *dir,
-									  gchar **filename, gint *line);
+									  gchar **filename, gint *line, gchar **type);
 
 gboolean msgwin_goto_messages_file_line(gboolean focus_editor);
 
-- 
1.8.3.2

_______________________________________________
Devel mailing list
Devel@lists.geany.org
https://lists.geany.org/cgi-bin/mailman/listinfo/devel

Reply via email to