SF.net SVN: geany: [2581] trunk

eht16 at users.sourceforge.net eht16 at xxxxx
Wed May 14 15:46:49 UTC 2008


Revision: 2581
          http://geany.svn.sourceforge.net/geany/?rev=2581&view=rev
Author:   eht16
Date:     2008-05-14 08:46:48 -0700 (Wed, 14 May 2008)

Log Message:
-----------
Add new function document_set_indicator_on_line() for future use.
Add some functions to the plugin API for the upcoming spell check plugin.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/src/build.c
    trunk/src/document.c
    trunk/src/document.h
    trunk/src/msgwindow.c
    trunk/src/msgwindow.h
    trunk/src/plugindata.h
    trunk/src/plugins.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2008-05-14 15:36:27 UTC (rev 2580)
+++ trunk/ChangeLog	2008-05-14 15:46:48 UTC (rev 2581)
@@ -8,6 +8,11 @@
    (closes #1895362) and to disable the automatic continuation of
    multi-line comments in C-like languages.
    Enable multi-line continuation also for CSS files.
+ * src/document.c, src/document.h, src/msgwindow.c, src/msgwindow.h,
+   src/plugins.c, src/plugindata.h:
+   Add new function document_set_indicator_on_line() for future use.
+   Add some functions to the plugin API for the upcoming spell check
+   plugin.
 
 
 2008-05-14  Nick Treleaven  <nick(dot)treleaven(at)btinternet(dot)com>

Modified: trunk/src/build.c
===================================================================
--- trunk/src/build.c	2008-05-14 15:36:27 UTC (rev 2580)
+++ trunk/src/build.c	2008-05-14 15:46:48 UTC (rev 2581)
@@ -855,7 +855,7 @@
 				{
 					gint idx = document_find_by_filename(filename, FALSE);
 
-					document_set_indicator(idx, line - 1);	/* will check valid idx */
+					document_set_indicator_on_line(idx, line - 1);	/* will check valid idx */
 					color = COLOR_RED;	/* error message parsed on the line */
 				}
 				g_free(filename);

Modified: trunk/src/document.c
===================================================================
--- trunk/src/document.c	2008-05-14 15:36:27 UTC (rev 2580)
+++ trunk/src/document.c	2008-05-14 15:46:48 UTC (rev 2581)
@@ -2203,6 +2203,12 @@
 }
 
 
+/**
+ *  Deletes all currently set indicators in the %document.
+ *  Error indicators (red squiggly underlines) and usual line markers are removed.
+ *
+ *  @param idx The document index to operate on.
+ **/
 void document_clear_indicators(gint idx)
 {
 	glong last_pos;
@@ -2219,13 +2225,22 @@
 }
 
 
-void document_set_indicator(gint idx, gint line)
+/**
+ *  This is a convenience function for document_set_indicator(). It sets an error indicator
+ *  (red squiggly underline) on the whole given line.
+ *  Whitespace at the start and the end of the line is not marked.
+ *
+ *  @param idx The %document index to operate on.
+ *  @param line The line number which should be marked.
+ **/
+void document_set_indicator_on_line(gint idx, gint line)
 {
-	gint start, end, current_mask;
+	gint start, end;
 	guint i = 0, len;
 	gchar *linebuf;
 
-	if (idx == -1 || ! doc_list[idx].is_valid) return;
+	if (! DOC_IDX_VALID(idx))
+		return;
 
 	start = sci_get_position_from_line(doc_list[idx].sci, line);
 	end = sci_get_position_from_line(doc_list[idx].sci, line + 1);
@@ -2240,15 +2255,39 @@
 	linebuf = sci_get_line(doc_list[idx].sci, line);
 
 	while (isspace(linebuf[i])) i++;
-	while (len > 1 && len > i && isspace(linebuf[len-1])) len--;
+	while (len > 1 && len > i && isspace(linebuf[len-1]))
+	{
+		len--;
+		end--;
+	}
 	g_free(linebuf);
 
+	document_set_indicator(idx, start + i, end);
+}
+
+
+/**
+ *  Sets an error indicator (red squiggly underline) on the range specified by @c start and @c end.
+ *  No error checking or whitespace removal is performed, this should be done by the calling
+ *  function if necessary.
+ *
+ *  @param idx The %document index to operate on.
+ *  @param start The starting position for the marker.
+ *  @param end The ending position for the marker.
+ **/
+void document_set_indicator(gint idx, gint start, gint end)
+{
+	gint current_mask;
+
+	if (! DOC_IDX_VALID(idx) || start >= end)
+		return;
+
 	current_mask = sci_get_style_at(doc_list[idx].sci, start);
 	current_mask &= INDICS_MASK;
 	current_mask |= INDIC2_MASK;
-	sci_start_styling(doc_list[idx].sci, start + i, INDIC2_MASK);
-	/*geany_debug("%p\tline: %d\tstart-end: %d - %d\t%d - %i", doc_list[idx].sci, line, start, end, len, i);*/
-	sci_set_styling(doc_list[idx].sci, len - i, current_mask);
+
+	sci_start_styling(doc_list[idx].sci, start, INDIC2_MASK);
+	sci_set_styling(doc_list[idx].sci, end - start, current_mask);
 }
 
 

Modified: trunk/src/document.h
===================================================================
--- trunk/src/document.h	2008-05-14 15:36:27 UTC (rev 2580)
+++ trunk/src/document.h	2008-05-14 15:46:48 UTC (rev 2581)
@@ -219,8 +219,10 @@
 
 void document_unfold_all(gint idx);
 
-void document_set_indicator(gint idx, gint line);
+void document_set_indicator_on_line(gint idx, gint line);
 
+void document_set_indicator(gint idx, gint start, gint end);
+
 void document_clear_indicators(gint idx);
 
 void document_replace_tabs(gint idx);

Modified: trunk/src/msgwindow.c
===================================================================
--- trunk/src/msgwindow.c	2008-05-14 15:36:27 UTC (rev 2580)
+++ trunk/src/msgwindow.c	2008-05-14 15:46:48 UTC (rev 2581)
@@ -213,6 +213,13 @@
 }
 
 
+/**
+ *  Adds a new message in the compiler tab treeview in the messages window.
+ *
+ *  @param msg_color A color to be used for the text. It must be an element of #MsgColors.
+ *  @param format Printf()-style format string.
+ *  @param ... Arguments for the @c format string.
+ **/
 void msgwin_compiler_add_fmt(gint msg_color, const gchar *format, ...)
 {
 	gchar string[512];
@@ -225,7 +232,6 @@
 }
 
 
-/* adds string to the compiler textview */
 void msgwin_compiler_add(gint msg_color, const gchar *msg)
 {
 	GtkTreeIter iter;
@@ -260,6 +266,17 @@
 }
 
 
+/**
+ *  Adds a new message in the messages tab treeview in the messages window.
+ *  If @c line and @c idx are set, clicking on this line jumps into the file which is specified
+ *  by @c idx into the line specified with @c line.
+ *
+ *  @param msg_color A color to be used for the text. It must be an element of #MsgColors.
+ *  @param line The document's line where the message belongs to. Set to -1 to ignore.
+ *  @param idx The document's index in the doc_array. Set to -1 to ignore.
+ *  @param format Printf()-style format string.
+ *  @param ... Arguments for the @c format string.
+ **/
 void msgwin_msg_add_fmt(gint msg_color, gint line, gint idx, const gchar *format, ...)
 {
 	gchar string[512];
@@ -299,8 +316,13 @@
 }
 
 
-/* Log a status message *without* setting the status bar.
- * (Use ui_set_statusbar() to display text on the statusbar) */
+/**
+ *  Log a status message *without* setting the status bar.
+ *  (Use ui_set_statusbar() to display text on the statusbar)
+ *
+ *  @param format Printf()-style format string.
+ *  @param ... Arguments for the @c format string.
+ **/
 void msgwin_status_add(const gchar *format, ...)
 {
 	GtkTreeIter iter;
@@ -520,7 +542,7 @@
 				if (DOC_IDX_VALID(idx))
 				{
 					if (! doc_list[idx].changed)	/* if modified, line may be wrong */
-						document_set_indicator(idx, line - 1);
+						document_set_indicator_on_line(idx, line - 1);
 
 					ret = navqueue_goto_line(old_idx, idx, line);
 				}
@@ -882,7 +904,15 @@
 }
 
 
-void msgwin_switch_tab(MessageWindowTabNum tabnum, gboolean show)
+/**
+ *  Switches to the given notebook tab of the messages window and shows the messages window
+ *  if it was previously hidden and @c show is set to @a TRUE.
+ *
+ *  @param tabnum An index of a tab in the messages window. Valid values are all elements of
+ *                #MessageWindowTabNum.
+ *  @param show Whether to show the messages window at all if it was hidden before.
+ **/
+void msgwin_switch_tab(gint tabnum, gboolean show)
 {
 	GtkWidget *widget = NULL;	/* widget to focus */
 
@@ -904,8 +934,13 @@
 		gtk_widget_grab_focus(widget);
 }
 
-
-void msgwin_clear_tab(MessageWindowTabNum tabnum)
+/**
+ *  Removes all messages from a tab specified by @c tabnum in the messages window.
+ *
+ *  @param tabnum An index of a tab in the messages window which should be cleared.
+ *                Valid values are @a MSG_STATUS, @a MSG_COMPILER and @a MSG_MESSAGE.
+ **/
+void msgwin_clear_tab(gint tabnum)
 {
 	GtkListStore *store = NULL;
 

Modified: trunk/src/msgwindow.h
===================================================================
--- trunk/src/msgwindow.h	2008-05-14 15:36:27 UTC (rev 2580)
+++ trunk/src/msgwindow.h	2008-05-14 15:46:48 UTC (rev 2581)
@@ -21,26 +21,37 @@
  * $Id$
  */
 
+/**
+ *  @file msgwindow.h
+ *  Message window functions (status, compiler, messages windows).
+ *  Also compiler error message parsing and grep file and line parsing.
+ **/
 
+
 #ifndef GEANY_MSGWINDOW_H
 #define GEANY_MSGWINDOW_H 1
 
 
-enum
+/**
+ * Various colors for use in the compiler and messages treeviews when adding messages.
+ **/
+enum MsgColors
 {
-	COLOR_RED,
-	COLOR_DARK_RED,
-	COLOR_BLACK,
-	COLOR_BLUE
+	COLOR_RED,		/**< Color red */
+	COLOR_DARK_RED,	/**< Color dark red */
+	COLOR_BLACK,	/**< Color black */
+	COLOR_BLUE		/**< Color blue */
 };
 
+/** Indices of the notebooks in the messages window. */
 typedef enum
 {
-	MSG_STATUS = 0, /* force it to start at 0 to keep in sync with the notebook page numbers */
-	MSG_COMPILER,
-	MSG_MESSAGE,
-	MSG_SCRATCH,
-	MSG_VTE
+	/* force it to start at 0 to keep in sync with the notebook page numbers */
+	MSG_STATUS = 0,	/**< Index of the status message tab */
+	MSG_COMPILER,	/**< Index of the compiler tab */
+	MSG_MESSAGE,	/**< Index of the messages tab */
+	MSG_SCRATCH,	/**< Index of the scratch tab */
+	MSG_VTE			/**< Index of the VTE tab */
 } MessageWindowTabNum;
 
 
@@ -69,9 +80,9 @@
 
 void msgwin_show_hide(gboolean show);
 
-void msgwin_switch_tab(MessageWindowTabNum tabnum, gboolean show);
+void msgwin_switch_tab(gint tabnum, gboolean show);
 
-void msgwin_clear_tab(MessageWindowTabNum tabnum);
+void msgwin_clear_tab(gint tabnum);
 
 void msgwin_msg_add_fmt(gint msg_color, gint line, gint idx, const gchar *format, ...) G_GNUC_PRINTF (4, 5);
 

Modified: trunk/src/plugindata.h
===================================================================
--- trunk/src/plugindata.h	2008-05-14 15:36:27 UTC (rev 2580)
+++ trunk/src/plugindata.h	2008-05-14 15:46:48 UTC (rev 2581)
@@ -202,6 +202,9 @@
 	void	(*set_encoding) (gint idx, const gchar *new_encoding);
 	void	(*set_text_changed) (gint idx);
 	void	(*set_filetype) (gint idx, filetype *type);
+	void	(*set_indicator) (gint idx, gint start, gint end);
+	void	(*set_indicator_on_line) (gint idx, gint line);
+	void	(*clear_indicators) (gint idx);
 }
 DocumentFuncs;
 
@@ -246,6 +249,7 @@
 	gint	(*get_style_at) (struct _ScintillaObject *sci, gint position);
 	gchar	(*get_char_at) (struct _ScintillaObject *sci, gint pos);
 	gint	(*get_current_line) (struct _ScintillaObject *sci);
+	gboolean (*can_copy) (struct _ScintillaObject *sci);
 }
 ScintillaFuncs;
 
@@ -326,6 +330,10 @@
 	/* status_add() does not set the status bar - use ui->set_statusbar() instead. */
 	void		(*status_add) (const gchar *format, ...);
 	void		(*compiler_add) (gint msg_color, const gchar *format, ...) G_GNUC_PRINTF (2, 3);
+	void		(*msg_add) (gint msg_color, gint line, gint idx, const gchar *format, ...)
+							G_GNUC_PRINTF (4, 5);
+	void		(*clear_tab) (gint tabnum);
+	void		(*switch_tab) (gint tabnum, gboolean show);
 }
 MsgWinFuncs;
 

Modified: trunk/src/plugins.c
===================================================================
--- trunk/src/plugins.c	2008-05-14 15:36:27 UTC (rev 2580)
+++ trunk/src/plugins.c	2008-05-14 15:46:48 UTC (rev 2581)
@@ -113,7 +113,10 @@
 	&document_reload_file,
 	&document_set_encoding,
 	&document_set_text_changed,
-	&document_set_filetype
+	&document_set_filetype,
+	&document_set_indicator,
+	&document_set_indicator_on_line,
+	&document_clear_indicators
 };
 
 static ScintillaFuncs sci_funcs = {
@@ -150,6 +153,7 @@
 	&sci_get_style_at,
 	&sci_get_char_at,
 	&sci_get_current_line,
+	&sci_can_copy
 };
 
 static TemplateFuncs template_funcs = {
@@ -193,7 +197,10 @@
 
 static MsgWinFuncs msgwin_funcs = {
 	&msgwin_status_add,
-	&msgwin_compiler_add_fmt
+	&msgwin_compiler_add_fmt,
+	&msgwin_msg_add_fmt,
+	&msgwin_clear_tab,
+	&msgwin_switch_tab
 };
 
 static EncodingFuncs encoding_funcs = {


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